voglio convertire JSON tramite biblioteca Jackson a una mappa contenente chiave camelCase ... diciamo ...Jackson JSON per mappare e CamelCase nome della chiave
da
{
"SomeKey": "SomeValue",
"AnotherKey": "another value",
"InnerJson" : {"TheKey" : "TheValue"}
}
a questo. ..
{
"someKey": "SomeValue",
"anotherKey": "another value",
"innerJson" : {"theKey" : "TheValue"}
}
My Code ...
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>>(){});
}
Ma questo non funziona ... anche altri propertyNamingStrategy non funziona su JSON ... come ...
{
"someKey": "SomeValue"
}
mapper.setPropertyNamingStrategy(new PropertyNamingStrategy.PascalCaseStrategy())
a
{
"SomeKey": "SomeValue"
}
Come ottenere il nome della chiave CamelCase Map tramite jackson ... o dovrei eseguire il loop manuale della mappa e convertire la chiave o ci sono altri modi ???
Grazie in anticipo ...
Questo guarda le linee di quello che stai cercando di ottenere: https: // github.com/FasterXML/jackson-databind/issues/62 –