如何替换“从字符串并形成有效的Json

时间:2019-08-02 06:24:48

标签: json escaping double-quotes

我有一个带有&Quot;的json字符串。代替双引号,并且json文本内也有引号。如何替换这些&Quot;用双引号仅与键和值相关联,而不与值(即json文本)相关联。

这是输入:

"description": "First: "Thank you"  always receive a very thorough examination and feel confident with my care"

and OutPut should be :  
"description": "First: "Thank you"  always receive a very thorough examination and feel confident with my care"

如果替换所有&Quot;它不会生成有效的json

引号即&Quot;谢谢,应该留在身边。

我从html页面的脚本标签中获得了这个json字符串,并且我将Java与Xpath一起使用来从脚本标签中获取内容,并且它带有编码为&Quot的双引号。这就是我获取字符串的方式< / p>

{&quot;@type&quot;: &quot;Review&quot;,
     &quot;reviewRating&quot;: {
       &quot;@type&quot;: &quot;Rating&quot;,
       &quot;ratingValue&quot;: &quot;5&quot;,
       &quot;bestRating&quot;: &quot;5&quot;,
       &quot;worstRating&quot;: &quot;1&quot;
     },
     &quot;description&quot;: &quot;First: &quot;Thank you&quot;  always receive a very thorough examination and feel confident with my care&quot;,
     &quot;author&quot;: {
       &quot;@type&quot;: &quot;Person&quot;,
       &quot;name&quot;: &quot;Anonymous&quot;
     }
   }

I just want to replace the &Quot value inside the text with any value apart from double quotes ,I don't have control over the source html here 

0 个答案:

没有答案