JSON-java icon indicating copy to clipboard operation
JSON-java copied to clipboard

JSONObject throws an exception when json conent has comment lines with latest json version

Open sandushi opened this issue 2 years ago • 2 comments

Description

We previously used json version 20070829 and we have comment lines in our json files. When we are going to upgrade json version to 20231013 , there is an exception when parsing the content to a json object.

A JSONObject text must begin with '{' at 1 [character 2 line 1]

Is there any way to upgrade the version without breaking?

sandushi avatar Nov 09 '23 03:11 sandushi

That certainly predates this repository history. A PR would need to be made to address supporting documents with comments. This would likely need to be added as a flag on the ParserConfiguration.java and passed through to the JSONTokener to support comments going forward.

johnjaylward avatar Nov 09 '23 04:11 johnjaylward

Please see #17. I think it will be better to support comments in a fork of this repo.

stleary avatar Nov 10 '23 02:11 stleary

Closing due to code is working as designed. Sorry for the behavior change, but that change was made before my tenure.

stleary avatar May 18 '25 16:05 stleary