Back
How do I convert a string variable jsonString into JSON object? Please help.
{"phonetype":"N95","dog":"WP"}
GSON g= new GSON();
try { JSONObject jsonObject = new JSONObject("{\"phonetype\":\"N95\",\"dog\":\"WP\"}");}catch (JSONException err){ Log.d("Error", err.toString());}
You can use the below-mentioned code:-
JSONParser parser = new JSONParser();JSONObject json = (JSONObject) parser.parse(stringToParse);
JSONParser parser = new JSONParser();
JSONObject json = (JSONObject) parser.parse(stringToParse);
You can use the following video tutorials to clear all your doubts:-
31k questions
32.8k answers
501 comments
693 users