将JSON结构转换为BasicDBObject
我想将以下json
结构转换为java中的BasicDBOject
并插入到mongo db中。
我的JSON结构是
{ "it": { "batch": "2013", "students": [ { "name": "joe" }, { "name": "john" } ] } }
com.mongodb.util.JSON有一个解析方法。
BasicDBObject实现DBObject
Object o = com.mongodb.util.JSON.parse("Your JSON structure or JSONObj.toString()"); DBObject dbObj = (DBObject) o;
com.mongodb.util.JSON.parse
已弃用
版本3.6.1使用后:
String json = "{"name": "joe"}"; Object o = BasicDBObject.parse(json);
按照此处: deprecated-list
- JDK8 CompletableFuture.supplyAsync如何处理interruptedException
- 使用Logback但Log4j开始显示WARN no Appender
- Spring Boot ConflictingBeanDefinitionException:@Controller类的注释指定bean名称
- JAX-WS和Joda-Time?
- 将参数传递给PrimeFaces星级组件?
- 在Switch Case Java中编译时间常量用法
- MalformedByteSequenceException:2字节UTF-8序列的无效字节2
- 如何在java中将UUID保存为二进制(16)
- JComponent大小问题