Search code examples
javajsondeserializationjson-deserializationboon

Replacing Jackson with Boon


I'm looking to replace Jackson deserialization with Boon to test the differences in deserialization speeds. I am reading JSON from a file (which can be in the millions of lines long), consisting of multiple blocks that will each represent a POJO instance (MyPojo.java)and storing these instances in a Collection. I also have a custom deserializer that will omit the creation of certain POJOs. At the minute I have the following in Jackson:

public Collection<MyPojo> load()
{
    ObjectMapper mapper = new ObjectMapper().registerModule(new MyCustomDeserializer());
    return mapper.readValue(jsonFile, new TypeReference<Collection<MyPojo>>(){});
}

I know that the Boon API mimics Jacksons so I tried:

ObjectMapper boonMapper = JsonFactory.create();
return boonMapper.readValue(jsonFile, new TypeReference<Collection<MyPojo>>(){});

...but it doesn't seem to like this, it can't find the method that accepts these types.

Forgetting the registering the custom deserializer for now (that'll be my next problem), is this type of deserialization, straight to a Collection, supported in Boon?


Solution

  • Do the following;

    return boonMapper.readValue(jsonFile, List.class, MyPojo.class);