Talib Talib - 8 months ago 123
Java Question

Converting string to json object using json.simple

I am using

org.json.simple.JSONObject
.
I want to convert
string
to Json
object
.

String value=request.getParameter("savepos");
JSONObject jsonObject = (JSONObject) JSONValue.parse(value);


It doesn't work. Why?

Answer Source

Try this:

JSONParser parser = new JSONParser();
JSONObject json = (JSONObject) parser.parse(stringToParse);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download