How to convert Java String to JSON Object

后端 未结 5 1266
暖寄归人
暖寄归人 2020-12-29 12:07

This question has been asked earlier, but I am unable to figure out the error in my code from the responses to those questions.


I am trying to convert a java s

5条回答
  •  隐瞒了意图╮
    2020-12-29 12:44

    You are passing into the JSONObject constructor an instance of a StringBuilder class.

    This is using the JSONObject(Object) constructor, not the JSONObject(String) one.

    Your code should be:

    JSONObject jsonObj = new JSONObject(jsonString.toString());
    

提交回复
热议问题