Remove quote from the JSONArray output

后端 未结 13 1863
野性不改
野性不改 2021-01-02 02:45

On the successful call, I am getting the JSONArray with the key \"objects\" and again the testValue with the key \"name\". The output is Like:



        
13条回答
  •  春和景丽
    2021-01-02 03:31

    Best option is to use .getString() method of JSONObject or .valueOf() method of String. You can also use the .replaceAll("\"",""), but this has some problems, when the string itself contains "(double quotes) embedded in it. So, avoid using the replaceAll() method to get out of the unexpected problems.

    But still, if you want to code on own by your hand or If you want to know how to delete the double quotes without using getString() and .valueOf(), you can try like this

    testValue.toString().subString(1,testValue.toString().length())
    

    it will give the sub string excluding first and last characters of the String. But, it seems like some messy thing.

提交回复
热议问题