conversion from string to json object android

后端 未结 8 1770
误落风尘
误落风尘 2020-11-30 00:39

I am working on an Android application. In my app I have to convert a string to Json Object, then parse the values. I checked for a solution in stackoverflow and found simil

8条回答
  •  有刺的猬
    2020-11-30 01:27

    just try this , finally this works for me :

    //delete backslashes ( \ ) :
                data = data.replaceAll("[\\\\]{1}[\"]{1}","\"");
    //delete first and last double quotation ( " ) :
                data = data.substring(data.indexOf("{"),data.lastIndexOf("}")+1);
                JSONObject json = new JSONObject(data);
    

提交回复
热议问题