Jackson overcoming underscores in favor of camel-case

I retrieve a JSON string from internet; like most JSON I’ve seen it includes long keys that are separated by underscores. Essentially, my goal is to deserialize JSON into java-objects, but I don’t use underscores in java-code.

For instance, I might have a User class with firstName field in camel-case, simultaneously I need somehow to tell Jackson to map first_name key from JSON to firstName class field. Is it possible?

class User{
    protected String firstName;
    protected String getFirstName(){return firstName;}
}

10 Answers
10

Leave a Comment