java how to convert a string to net.sf.json.JSONObject -
i tweets , use org.json.simple api convert string object.
jsonparser jsonparser = new jsonparser(); object json = jsonparser.parse(in);
and insert obj couchdb using couchdb4j api
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);
the error is:
org.json.simple.jsonobject cannot cast net.sf.json.jsonobject
how solve problem or can give solution insert json format string or object couchdb
as error said, couchdb may use net.sf.json.jsonobject.
i've found api in net.sf.json.jsonobject convert string json object:
public static jsonobject fromobject( object object ) { return fromobject( object, new jsonconfig() ); }
it's ok string cause
else if( object instanceof string ){ return _fromstring( (string) object, jsonconfig ); }
this may help.
Comments
Post a Comment