java - Jackson JSON not able to deserialize array of elements with custom root name? -


I have a Jason that looks like this:

  {"testEntities": [ "id": 1, "float" number: 0.006117165, "float Anmber object": 0.15273619, "Intanmber" -115 586 9 325, "Intunmber object": 431529176, "double number" .41008081149220166, "Dblnmberobjekt" .20771484130971707 "Sortnmber": 9364, "bill", "B", "Boolean value" true "Boolean value object": true, "byte value" -79 "Charvelv": "e", "Charwu object ":" B "," creation date ": 86400000}, {" id ": 2," float number ": 0.9874208, "Float Member Object": 0.45285606, "Intanember": -1154715079, "Entrepreneur Object": 1260042744, "Double Number": 0.9014476240300544, "DublinAmbject": 0.49682259343089075, "Shortenumber": 483, "Shortenumber Object": 18322, Boolean value "false" Boolean value object ": true," byte value "-73" Charwhlu ":" C "," charValueObject ":" r "," creationDate ": 172800000}]}  

When I try to deserialize it, it fails in:

  By: com.fasterxml.jackson.databind.JsonMappingException : The root name does not match the expected 'testObject []' type for the 'testEntities' type  

I already have array deserialization enabled:

  ObjectMapper.enable (DeserializationFeature.USE_JAVA_ARRAY_FOR_JSON_ARRAY);  

Obviously, testEntities is a custom name that does not know anything about Jackson, a custom in the TestObject class annotations that I JsonRootNamePlural a custom made annotation, when core element called a collection instead of a collection:

  @ Jesntutnampulik @ Jesnrutnam ( "Test Anntaiti") ("Testanties") Public Class Test Object {...}  

Other types of arrangement for this annotation It is also necessary on police station.

I want to use it the same way as it uses the @JsonRootName annotation, except that it can look for the root element for the array As JasonTutan has indicated, and if no one is found, then he can look for the @JesRunootnamplural. All other basic names by Jackson should be ignored.

The question is, What should I override or customize to implement this behavior?

Any thanks or pointers are appreciated, thanks!

I got an answer to my own question: need to set map A custom example of which overrides the findRootName method, and checks that the class is an ARM and if so look for custom annotations in the array component class like:

  @ Override Find public properties Root name (annotatedclass ac) {// if it is a array For J3RootNamePlural Annotation, see // Base type for array (the so-called array component) if (ac.getRawType () .isArray ()) {class  

Hope this will help others,

Cheers!


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -