Java escape JSON String?

前端 未结 10 637
再見小時候
再見小時候 2020-12-08 11:27

I have the following JSON string that i am sending to a NodeJS server:

String string = \"{\\\"id\\\":\\\"\" + userID + \"\\\",\\\"type\\\":\\\"\" + methoden          


        
10条回答
  •  萌比男神i
    2020-12-08 11:51

    According to the answer here, quotes in values need to be escaped. You can do that with \"

    So just repalce the quote in your values

    msget = msget.replace("\"", "\\\"");
    

提交回复
热议问题