Question

I want to selectively ignore JSON properties during the deserialization phase. I'm currently dealing with a huge JSON file that takes ages to deserialize on slow Android devices and I would like to specify some properties not to be deserialized at different stages of the app lifecycle. The problem is, sometimes I need the data and I need to be able to deserialize the ignored data when I actually need it.

I'm using Jackson and ObjectMapper.

Example POJO:

public class Pojo {
    private String name;
    private Map<String, String> data;

    ...
}

Example JSON:

{
    "pojos" : [ {
        name : "Name",
        data : {
            "somedata1" : "somevalue1",
            "somedata2" : "somevalue2",
            "somedata3" : "somevalue3"
            ...
        }
    } ]
}

There will be great amount of "pojos" and each "data" property will get HUGE. So I would like to sometimes deserialize with ignoring the "data" property. Sometimes I want the "data" to deserialize normally.

Était-ce utile?

La solution

by using different classes you can create a superclass that fits with the class in the service interface and then create 2 or more subclasses...so hopefully nothing should be changed in the service

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top