Page 1 of 1

Collection.query not returning valid JSON?

Posted: Sat Jun 20, 2015 2:29 pm
by LukeM

Hi,

i'm trying to use Collection.query in Server Code but the results do not seem to be valid JSON.

I get an error on:

var result = Collection.query(dbId,
collectionNameA, queryStringA, tokenID);

console.log(result);
var obj = JSON.parse(result);

[SyntaxError: Unexpected token o]

if I copy paste from Trace to JSONLint, it says:

Parse error on line 1:
{ _id: '55770da3e4b0ce
-----^
Expecting 'STRING', '}'


Collection.query not returning valid JSON?

Posted: Sat Jun 20, 2015 3:05 pm
by LukeM

Actually, I was just messing up my JSON parsing, i was expecting a string, and it's returning an Object.

console.log(result[0]._id);<

got me back on track.

( Might be helpful for other noobs.)


Collection.query not returning valid JSON?

Posted: Sat Jun 20, 2015 3:13 pm
by Alena Prykhodko

Thank you for update.