Is there a way to run MongoDB shell (or tojson met

2019-02-23 00:35发布

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)

1条回答
神经病院院长
2楼-- · 2019-02-23 01:07

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.

查看更多
登录 后发表回答