Search code examples
javajsonjax-rsjersey-2.0pojo

Turning JSON list into POJO


Here's the JSON:

{  
   "Want":{  
      "ABCD-1234-ABCD-1234-ABCD-125A":3,
      "ABCD-1234-ABCD-1234-ABCD-129B":5,
      "ABCD-1234-ABCD-1234-ABCD-123C":10
   },
   "EndPoint":"https://example.com/gossip/asff3"
}

And my current POJO:

public class WantMessage {

@JsonProperty("Want")
    Map<String, String> wantmap = new HashMap<String, String>();
@JsonProperty("EndPoint")
    public String EndPoint;
}

I get the "Endpoint" String in ok but am missing the data in the "Want" section. How would you pull in the want list?


Solution

  • wantmap has keys and values of type String. The map in json has int values. Try putting the numbers in double quotes, and see if it works.