Search code examples
javajsonspringmongodbpojo

How to make java POJO for this json?


I'm curious about how to make a POJO when the key values are numeric as given in the given JSON object.

{
    "id" : 1,

    "options": {
        "1": "a",
        "2": "b",
        "3": "c",
        "4": "e"
    }
}

as you can see options have numeric values as a key, so how to make java POJO out of it, as a variable name cannot be numeric.


Solution

  • Use something like this

    public class MyPojo {
    
        private int id;
        private Map<Integer, String> options;
    
    }