对于Java数据处理程序,我发送了格式正确的JSON,但是Spring、决定如何转换它所看到的内容的Java和框架的组合,我真的不应该go 更改JSON,这样一旦我可以看到它,它就会变成LinkedTreeMap,我需要把它转换成JsonObject. 这不是要将JSON序列化/反序列化为Java对象,它的"最终形式"是一个gson JsonObject,它需要能够处理任何有效的JSON.
{
"key":"value",
"object": {
"array":[
"value1",
"please work"
]
}
}
是我一直在使用的示例,一旦我看到它,它就是一个链接的 map .toString()s to
{key=value, object={array=[value1, please work]}}
where you can replace "=" with ":", but that doesn't have the internal quotes for the
new JsonParser().parse(gson.toJson(STRING)).getAsJsonObject()
strategy.
Is there a more direct way to convert LinkedTreeMap to JsonObject, or a library to add the internal quotes to the string, or even a way to turn a sting into a JsonObject that doesn't need the internal quotes?