{"name":"John Doe","age":30,"emailAddress":"johndoe@example.com"}
to
{"name":"John Doe","age":30,"email_address":"johndoe@example.com"}{
"SomeKey": "SomeValue",
"AnotherKey": "another value",
"InnerJson" : {"TheKey" : "TheValue"}
}
到这个地步...
{
"someKey": "SomeValue",
"anotherKey": "another value",
"innerJson" : {"theKey" : "TheValue"}
}
我的代码...
public Map<String, Object> jsonToMap(String jsonString) throws IOException
{
ObjectMapper mapper=new ObjectMapper();
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
return mapper.readValue(jsonString,new TypeReference<Map<String, Object>>(){});
}
但这不起作用...甚至其他的 propertyNamingStrategy 在 JSON 上也不起作用,例如...
{
"someKey": "SomeValue"
}
mapper.setPropertyNamingStrategy(new PropertyNamingStrategy.PascalCaseStrategy())
到
{
"SomeKey": "SomeValue"
}
如何通过Jackson获取camelCase Map键名... 或者我是否需要手动循环Map并转换键名,或者是否有其他方法?
提前致谢...