json - 如何从字符串中替换“并形成有效的Json
问题描述
我有一个带有 &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 的双引号。这就是我获取字符串的方式
{"@type": "Review",
"reviewRating": {
"@type": "Rating",
"ratingValue": "5",
"bestRating": "5",
"worstRating": "1"
},
"description": "First: "Thank you" always receive a very thorough examination and feel confident with my care",
"author": {
"@type": "Person",
"name": "Anonymous"
}
}
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
解决方案
推荐阅读
- excel - 为什么 INDIRECT() 不适用于具有工作表范围的动态命名范围?
- performance - BQ中的嵌套vs连接
- javascript - 如何在不每次都创建新会话的情况下一个接一个地执行appium测试脚本?
- ruby-on-rails - 将 end_time 值设置为与 rails 表单中的 start_time 值相同
- java - Android Studio - 与预览版和模拟器相比,物理设备上的布局元素大小不同
- javascript - 如何在 Vue3 中使用 GoogleChart
- azure-devops - 为 CMMI 流程 Azure DevOps 板中的任务指定计划(开始日期、完成日期)
- javascript - 如何使用 React 访问单独的 .js 文件中的状态值?
- python - 如何从这个均值函数中排除零点?
- python - 在每个barplot pptx python的顶部添加pourcentage