jdereg / json-io

Convert Java to JSON. Convert JSON to Java. Pretty print JSON. Java JSON serializer. Deep copy Java object graphs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow tolerant/lenient parser of +/- infinity and NaN

antoinetran opened this issue · comments

Hi,

I know JSON norms does not accept these value, but in our project, we need to have NaN or Infinity, as this is provided by our scientific data. Maybe we shouldn't have used Json, but now we would like to have a Json Parser a bit more lenient, as the Gson parser, that with a configuration, can read and write NaN and +/- infinity. Thank you!

Maybe there should be a singleton like JsonConfig.setLenient(true), or a configuration per usage, like
JsonReader.jsonToJava(line, LENIENT);

Pull request #138

I've merged this change in. Thank you for contributing. Need to wrap this up with test case, then can release.

Pull request #139 as requested, 2 UT class.

The test suite was failing due to the added test setting the value 'lenient' to true but not restoring it. This has been fixed and checked in. I am putting together a new release that will include this.

This is now supported (thank you @antoinetran) and will be released in 4.11.0.