我得到推文並使用org.json.simple api將字符串轉換爲對象。如何將字符串轉換爲net.sf.json.JSONObject
JSONParser jsonParser = new JSONParser();
Object json = jsonParser.parse(in);
,我想用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);
的錯誤是:
org.json.simple.JSONObject cannot be cast to net.sf.json.JSONObject
如何解決這個問題,或者任何人都可以給出一個解決方案插入一個JSON格式的字符串或對象到沙發數據庫
檢查進口,確保您使用的庫JSON解析正確的,那就是如果你正在使用json.simple,那麼這將是最好不要使用'net.sf. json.JSONObject'對象。 – Jhanvi