LukeM
Posts: 0
Joined: Sat Nov 15, 2014 4:43 pm

Collection.query not returning valid JSON?

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', '}'

LukeM
Posts: 0
Joined: Sat Nov 15, 2014 4:43 pm

Collection.query not returning valid JSON?

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.)

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Collection.query not returning valid JSON?

Thank you for update.

Return to “Issues”