Mr. Sajid Shaikh Mr. Sajid Shaikh - 4 months ago 17
JSON Question

How to convert String to JSONObject in Java

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...

Answer

Using org.json library:

    JSONObject jsonObj = new JSONObject("{\"phonetype\":\"N95\",\"cat\":\"WP\"}");
Comments