-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The validator thinks -0 is a string. not a number #25
Comments
@coderextreme thanks for reporting it. I'm afraid I can't fix it, because this problem is caused by a bug of the underlying org.json API (more specifically the JSONTokener#nextValue() and/or the JSONObject#stringToValue()` methods). I've tried to find a workaround for it, but it seems the parser notoriously parses the edit: minimal snippet about my findings: JSONObject input = new JSONObject("{\"prop\" : \"-0\"}");
System.out.println(input.get("prop") + " " + input.get("prop").getClass());
input = new JSONObject("{\"prop\" : -0}");
System.out.println(input.get("prop") + " " + input.get("prop").getClass());
input = new JSONObject("{\"prop\" : -0.0}");
System.out.println(input.get("prop") + " " + input.get("prop").getClass()); It prints:
So both |
Can we use something besides JSONTokener?
|
Well I'm not going to reimplement the tokener from scratch. I'll look after how much time does it take to fix the org.json implementation. |
I was thinking of doing a JSON.parse() and working with that result, but
|
Or maybe we could switch to gson if it's better.
|
I filed an issue here against org.json: stleary/JSON-java#187 |
As the most simple temporary solution I recommend using |
I don’t control the JSON but I can make a recommendation. John
|
A pull request containing the fix can be found here: stleary/JSON-java#188. Feel free to try it out and let us know whether it addresses the issue. |
Thanks. Our JSON passes through now (at least that area). We had over 6300 instances of -0 so this was pretty critical. John
|
@stleary how are the artifacts deployed to maven central? From my side, fixing this issue will only mean upgrading (in my pom.xml) to the version containing the bugfix. |
…C Licensed existing subject-valid.json file - see #80 for details
See attached CC.txt JSON document and Schema.txt JSON schema
CC.txt
Schema.txt
The text was updated successfully, but these errors were encountered: