I have String variable called jsonString
:
{"phonetype":"N95","cat":"WP"}
Now I want to convert it into JSON Object. I searched more on Google but didn't get any expected answers...
I have String variable called jsonString
:
{"phonetype":"N95","cat":"WP"}
Now I want to convert it into JSON Object. I searched more on Google but didn't get any expected answers...
To convert a string to json and the sting is like json. {"phonetype":"N95","cat":"WP"}
Java 7 solution
;
you must import org.json
If you are using http://json-lib.sourceforge.net (net.sf.json.JSONObject)
it is pretty easy:
or
get the values then with json.getString(param), json.getInt(param) and so on.
Use JsonNode of fasterxml for the Generic Json Parsing. It internally creates a Map of key value for all the inputs.
Example:
input String :
To anyone still looking for an answer: