Search code examples
javajsonpojo

Convert JSON with integers to Java POJO objects


I have this JSON data, and I was wondering how I might convert this data to a Java POJO object:

"progression": {
    "64693": [
        {
            "1": 1
        }
    ],
    "64717": [
        {
            "1": 4
        }
    ]
},

I was thinking it can't be:

public class Progression{
private List<64693> 64693;
private List<64717> 64717;

public List<64693> get64693(){
    return this.64693;
}
public void set64693(List<64693> 64693){
    this.64693 = 64693;
}
public List<64717> get64717(){
    return this.64717;
}
public void set64717(List<64717> 64717){
    this.64717 = 64717;
}
}

I'm very familiar with Java, so I know I can do a @JsonProperty instead of the actual numbers, but just wondering if there were any other choices.

Thanks!


Solution

  • _ug had the right suggestion:

    ... object consider naming 64693 to like DataType64693 and adding the @JsonProperty("64693") annotation

    That worked fine. And BTW, I am using the Jackson 2.0 JSON processor.