有没有一种方法可以在严格的JSON模式下运行MongoDB Shell(或tojson方法)? [英] Is there a way to run MongoDB shell (or tojson method) in strict JSON mode?

查看:241
本文介绍了有没有一种方法可以在严格的JSON模式下运行MongoDB Shell(或tojson方法)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

严格 JSON模式?

为什么我需要这样做-为了能够获取shell的输出(由某些js命令生成,然后由tojson生成)并将其转换为Java中的JSON对象.

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.

或者,

有什么方法可以将扩展的JSON从外壳解析为Java Json对象吗? ( com.mongodb.util.JSON.parse 需要严格的JSON)

Is there any way to parse the extended JSON from shell into java Json objects? (com.mongodb.util.JSON.parse expects strict JSON)

推荐答案

解决方法:您可以在REST模式下启动Mongo,并且REST模式确实返回严格的JSON.不知道您是否可以通过外壳访问REST,但这可以解决您的问题.

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.

从技术上讲,只有严格的JSON,因此,如果to_json()方法生成无效的JSON输出,那么我将在 https://jira.mongodb.org/secure/Dashboard.jspa

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

此外,如果您要给出一个示例,说明要使用to_json()输出的内容,那么人们也许可以为您提供更具体的帮助.

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.

这篇关于有没有一种方法可以在严格的JSON模式下运行MongoDB Shell(或tojson方法)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆