我收到推文并使用 org.json.simple api 将字符串转换为对象。
JSONParser jsonParser = new JSONParser();
Object json = jsonParser.parse(in);
Run Code Online (Sandbox Code Playgroud)
我想使用 couchdb4j api 将 obj 插入到 couchdb
Session myDbSession = new Session("localhost",5984)
Database myCouchDb = myDbSession.getDatabase("db-name");
Document newdoc = new Document();
Document newdoc = new Document(JSONObject json);
myCouchDb.saveDocument(newdoc);
Run Code Online (Sandbox Code Playgroud)
错误是:
org.json.simple.JSONObject cannot be cast to net.sf.json.JSONObject
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题或者任何人都可以给出将json格式字符串或对象插入到couchdb中的解决方案