java - 删除使用 GSON 创建的 JSON 字符串中的双引号
问题描述
使用 GSON 库后,我得到了以下火花结果。
[
"{"A":"1","A-Description":"Eastern "}",
"{"B":"2","B-Description":"Western "}",
"{"C":"3","C-Description":"Northern "}",
"{"D":"4","D-Description":"Southern"}"
]
我想从 json 字符串的开头和结尾删除双引号
最终结果如下:
[
{"A":"1","A-Description":"Eastern "},
{"B":"2","B-Description":"Western "},
{"C":"3","C-Description":"Northern "},
{"D":"4","D-Description":"Southern"}
]
我已经解决了以下问题:
val jsonString = str.replaceAll("\\\\", "").replaceAll("\"(.+)\"", "$1")
其中 str 是一些字符串。
如果可用,请提出更有效的方法。
解决方案
推荐阅读
- android - 应用 Material Design 后,我的 UI 不再工作
- html - Galaxy S7 上的媒体查询
- python - 如果用户没有回答是或否,我如何重复我的迭代
- javascript - 您可能需要适当的加载程序来处理 ReactJS 文件中发生的这种文件类型错误
- php - PHP删除txt行,然后删除行有效但如果删除是最后一行,它不会删除空行
- javascript - 在 chrome 控制台 textarea class="form-control" 中清除文本字段区域
- java - Android:布尔变化的监听器
- python - 删除字符串中的特定项目?
- android - 配方 App 空指针异常 FireBase
- php - PHP从图像中删除黑条