Is there a way to run MongoDB shell (or particular tojson method) in strict JSON mode?
Why I need this - To be able take the output of shell (generated by some js commands followed by a tojson) and convert it to JSON objects in Java.
Alternatively,
Is there any way to parse the extended JSON from shell into java Json objects? (com.mongodb.util.JSON.parse expects strict JSON)
Workaround: you can start Mongo in REST mode and the REST mode does return strict JSON. Not sure if you can access REST through the shell but it would solve your problem.
Technically there is only strict JSON, so if the to_json() method is generating invalid JSON output then I would file a bug at https://jira.mongodb.org/secure/Dashboard.jspa
In addition, if you would give an example of what you are trying to output using to_json() then people might be able to offer you more specific help.