使用GSON库后,我在spark中得到了以下结果。
[
"{"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是一些字符串。
请提出更有效的方法。