不多说直接上方法:
原结构:
{
"message": {
"msgId":"14525F1D-0BAC-40F7-B522-365880B1B33F",
"content":"测试"num1"消息"
}
}
content的值里面有双"
解决方法:
方案1:
如果是无在乎中英文的区别可以用中文双引号替换。
如:测试“num1”消息
方案2:
可以将content的值encode一下再传入。
方案3:将"用\"" 代替,这个好处是可以用@排版。如下:
string strJson = @"{
""message"": {
""msgId"":""14525F1D-0BAC-40F7-B522-365880B1B33F"",
""content"":""测试\""num1\""消息""
}
}";
方案4:将"用\" 转义,如下:
string strJson="{\"message\": {\"content\":\"测试\\\"num1\\\"消息\"}}";