+ Start a Discussion

JSONObject unable to parse simple JSON string

I have a simple JSON string that I'm trying to parse using the open source JSONObject class from the code share.


Here's the string:



{"items":[{"name":"widget 1","productCode":"w1", "price":5,"units":1}], "subtotal":5, "total":8.56, "salesTax":3.56, "shippingCharge":0, "shipping":6}


 To parse this, I'm simply doing:



JSONObject json = new JSONObject(decoded);


Where "decoded" is the JSON string.


The I'm getting a TypeException with the message: "Invalid integer: 8.56"


Obviously, it's not an integer -- how can this be parsed as a double?



Can you please share the code of JSONObject class?


I am working on an implementation, and unable to retrieve it as codeShare link is broken.