function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ryanhcaryanhca 

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?

 

SatgurSatgur

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.