杰克逊 json 到地图和驼峰键名
我想通过杰克逊库将json转换为包含骆驼大小写键的地图...说。。。
从
{
"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>>(){});
}
但这行不通...甚至其他属性命名策略也不适用于json...如。。。
{
"someKey": "SomeValue"
}
mapper.setPropertyNamingStrategy(new PropertyNamingStrategy.PascalCaseStrategy())
自
{
"SomeKey": "SomeValue"
}
如何通过杰克逊获取骆驼案例地图键名...或者我应该手动循环映射并转换键,或者有其他方法???
提前致谢...