Ich arbeite mit jackson-core-2.8.3 und ich habe eine json, die Element in mehreren Fällen zur Verfügung gestellt hat. Ich möchte es meiner Klasse zuordnen, aber ich kann das nicht, weil ich in meiner Klasse nur eine Art von PropertyNamingStratergy haben kann.Wie mehrere Fälle mit Jackson
Beispiel Json: -
{"tableKey": "1","not_allowed_pwd": 10}
kann es eine andere json wie
{"tableKey": "1","notAllowedPwd": 10}
ClassToMap: -
class MyClass {
public String tableKey;
public Integer notAllowedPwd;
}
ObjectMapper Code: -
ObjectMapperobjectMapper=new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false);
objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES,true);
objectMapper.setSerializationInclusion(Include.NON_NULL);
objectMapper.setVisibility(PropertyAccessor.ALL,Visibility.NONE);
objectMapper.setVisibility(PropertyAccessor.FIELD,Visibility.ANY);
MyClass obj = objectMapper.readValue(s, MyClass.class);
Ich finde nirgendwo eine Lösung. Es wird gut sein, wenn jemand helfen kann, wie es weitergeht.
Werfen Sie einen Blick auf http://stackoverflow.com/questions/12583638/when-is-the-jsonproperty-property-used-and-what-isit-used-for –
Dieser Link könnte Ihnen helfen http://websystique.com/java/json/jackson-json-annotations-example/ –
Das Problem ist, dass JSON Call to Call variieren kann, so kann Snakecase Camelcase Format sein – Swaraj