I have a problem with parsing JSON integer in my REST service. Parsing String and double type work fine
AT:
JSONParser parser = new JSONParser();
Object obj = null;
try {
obj = parser.parse(input);
} catch (ParseException e) {
e.printStackTrace();
}
JSONObject jsonObject = (JSONObject) obj;
String uName = (String) jsonObject.get("userName");
double iPrice = (Double) jsonObject.get("itemPrice");
Does not work:
int baskId = (Integer) jsonObject.get("basketId");
I tried converting the basketIdbasket to String into my class, and then it functions fine, so the code is fine and the link works, however, when I return it back to int, I get 500 server errors. I use it to create a new basket with some numerical identifier, so I use the @POST annotation, and the JSON in the payload looks like this:
{"basketId":50}
I do not understand...
EDIT: I get this ... JSON simple only accepts larger types of Java primitives, so integer and float are no-no