Shades88
Shades88

Reputation: 8360

JSONParser fails while parsing very large numbers

I am using org.json.simple.parser JSON Parser. One specific data contained very large numbers. For example it once failed while parsing a line with this error

java.lang.NumberFormatException: For input string: "982134839798321390034432432"

Clearly it should be parsed with BigInt data type. Or there should be an option to treat these just as strings. What can be done in this case?

Upvotes: 0

Views: 626

Answers (1)

Rich
Rich

Reputation: 15464

This is a known issue in "json-simple", see https://github.com/fangyidong/json-simple/issues/73

You need to either:

  1. Switch to a different JSON parser, for example https://github.com/FasterXML/jackson
  2. Apply the patch on issue #73 to a private fork of "json-simple" and use that instead of the released version, or use "loegering"s fork at https://cliftonlabs.github.io/json-simple/ (linked from issue #73)

Upvotes: 1

Related Questions