How to convert jsonString to JSONObject in Java

前端 未结 19 3000
一生所求
一生所求 2020-11-22 00:39

I have String variable called jsonString:

{\"phonetype\":\"N95\",\"cat\":\"WP\"}

Now I want to convert it into JSON Object. I

19条回答
  •  有刺的猬
    2020-11-22 01:34

    Using org.json library:

    try {
         JSONObject jsonObject = new JSONObject("{\"phonetype\":\"N95\",\"cat\":\"WP\"}");
    }catch (JSONException err){
         Log.d("Error", err.toString());
    }
    

提交回复
热议问题