How to convert jsonString to JSONObject in Java

前端 未结 19 3007
一生所求
一生所求 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:24

    you must import org.json

    JSONObject jsonObj = null;
            try {
                jsonObj = new JSONObject("{\"phonetype\":\"N95\",\"cat\":\"WP\"}");
            } catch (JSONException e) {
                e.printStackTrace();
            }
    

提交回复
热议问题