2

Case is as follows:

I recieve a Json similar to this:

{
nodeProperties: 
      {
        node: {
            @id: "00:00:82:b6:ba:b6:5e:43"
            @type: "OF"
        },
        properties: {
            property: null,
            tables: {
                 tablesValue: "-2"
            },
            actions: {
             actionsValue: "4095"
            },
        ... 
    }
}

Deserialization goes through Jackson v.1.9 & Java7

Properties are deserialized and stored into this "nodeProperties" attribute:

private java.util.List<Property> _properties;

And all "properties" fall into subclass polimorphism of Property abstract class. Annotations for this to happen shall they be correctly inserted in the parent class and all subclasses.

Problem is: the JSON includes almost always that "property : null" which should be in fact a pojo class (NullProperty or whatever), or just ignored (as when it is actually null, i don't care at all), but i can't seem to find a way of any of these 2 solutions to make it work.

When I define (for example) a NullProperty subclass (completly void, without anything):

Can not deserialize instance of ...properties.NullProperty out of VALUE_NULL token

Nor i can find a way to ignore the null value. Else when not defining it:

Could not resolve type id 'property' into a subtype of [simple type, class ...properties.Property]

Nor I find the way to ignore it.

Any help will be so greatly appreciated.

  • Could you share the details of your classes and their Jackson annotations? That would help a lot. – Petr Jul 01 '13 at 18:51
  • Perhaps using a [custom deserializer](http://stackoverflow.com/a/15294114/1333025) for this particular class could help - you could replace `null` with an object of your choice. However this will probably work only if you don't have `null`s anywhere else inside `properties`. – Petr Jul 01 '13 at 18:59
  • Maybe you should try to disable DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES feature in ObjectMapper with your second solution? – Michał Ziober Jul 01 '13 at 23:29

0 Answers0