raw mongodb query json parse error

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

raw mongodb query json parse error

Jayesh Nambiar
Hi All,
I've been playing around with executing raw mongodb queries with opensips 2.3.2. Though I can run and execute queries successfully I cannot figure how to write a query that queries the objectId in mongodb directly.
The raw query basically is:

db.runCommand({ find: "customers", filter: { "_id":ObjectId("5a212d183f1e5e1c7b11b194") } });

But When i write it in the script as:

cache_raw_query("mongodb:instance1", "{ \"find\": \"customers\", \"filter\": { \"_id\": ObjectId(\"5a212d183f1e5e1c7b11b194\") }}","$avp(out)");

opensips gives json parsing error. It basically expects the entire ObjectId string to be in inverted commas to be a valid json. Any ideas on how to successfully write the above working query in opensips to pass as a raw query.

Thanks,

- Jayesh


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: raw mongodb query json parse error

Liviu Chircu

Hi Jayesh,

I completely missed this idea during the module upgrade to libmongoc 1.6. I don't immediately see a way we can make this work without some development so that ObjectId() is somehow tolerated within a JSON (maybe some JSON library parsing flag? hopefully!). I've opened up an issue for this [1] - let's move the discussion over there.

Best regards,

[1]: https://github.com/OpenSIPS/opensips/issues/1229

Liviu Chircu
OpenSIPS Developer
http://www.opensips-solutions.com
On 01.12.2017 14:21, Jayesh Nambiar wrote:
Hi All,
I've been playing around with executing raw mongodb queries with opensips 2.3.2. Though I can run and execute queries successfully I cannot figure how to write a query that queries the objectId in mongodb directly.
The raw query basically is:

db.runCommand({ find: "customers", filter: { "_id":ObjectId("5a212d183f1e5e1c7b11b194") } });

But When i write it in the script as:

cache_raw_query("mongodb:instance1", "{ \"find\": \"customers\", \"filter\": { \"_id\": ObjectId(\"5a212d183f1e5e1c7b11b194\") }}","$avp(out)");

opensips gives json parsing error. It basically expects the entire ObjectId string to be in inverted commas to be a valid json. Any ideas on how to successfully write the above working query in opensips to pass as a raw query.

Thanks,

- Jayesh



_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users