How to escape the quotes in JSON Object?

后端 未结 4 1514
予麋鹿
予麋鹿 2021-01-19 17:31

Below is my method which makes the JSONObject and then print out the JSONString.

I am using Google GSON.

private String gen         


        
4条回答
  •  情书的邮戳
    2021-01-19 18:30

    Maybe try regex if you really need a string...

    string.replace(new RegExp('("\\[)', 'g'), '[').replace(new RegExp('(\\]")', 'g'), ']')
    

    Better explained, "[ is replaced with [ and ]" is replaced with ]

    Question was not his method of working with the JSON Object, it was how to escape array quotes.

提交回复
热议问题