Commit Graph
19 Commits
Author SHA1 Message Date
John J. Aylward 2f2cd4dfc5 Fix for number output bug.
java.lang.Number is currently output without any validation. For all java.* Numbers, this is fine, but for custom Number implementations like Complex or Fraction, the resulting JSON output may be invalid.

For example: If a Fraction implementation defines its' toString method as `return numerator + "/" + denominator`, then the resulting JSON output would be something like this:

```json
{ "fraction" : 1/2 }
```

This is not valid JSON.

This commit verifies that the string representation of the number is close to a JSON formatted number by use of the BigDecimal constructor. If the constructor throws a NumberFormatException, then the string value is instead quoted as a string. The example above would instead output like the following:

```json
{ "fraction" : "1/2" }
```
2016-08-17 12:54:30 -04:00
John J. Aylward 09d37e59b8 Cleans up the JSONML changes and adds similar changes to the XML class 2016-07-18 14:42:21 -04:00
John J. Aylward 93704371bb Updates to the Javadoc for exceptions 2016-07-18 14:12:06 -04:00
John J. Aylward 42791ab12d Updates README to note that the parser does allow some invalid JSON 2016-06-16 13:01:22 -04:00
John J. Aylward c2b3f2bdb1 adds back in the XML.stringToValue method, but deprecates it. 2016-01-27 15:21:11 -05:00
John J. Aylward 3007fc8ebe Removes custom XML stringToValue method in favor of keeping a consistent
implementation in JSONObject
2016-01-27 15:03:19 -05:00
John J. Aylward 39b1c0cb66 fixes error in -0 check 2016-01-27 10:45:23 -05:00
John J. Aylward 07b2d65e30 Fixes #187 -0 now returns as a double. 2016-01-27 10:39:31 -05:00
John J. Aylward 5b67330b71 Merge branch 'master' of https://github.com/douglascrockford/JSON-java 2016-01-27 09:53:03 -05:00
John J. Aylward 48302592cf Merge branch 'master' of https://github.com/douglascrockford/JSON-java 2015-12-09 10:07:36 -05:00
John J. Aylward ec8f649467 Merge branch 'master' of https://github.com/douglascrockford/JSON-java 2015-12-08 09:27:54 -05:00
John J. Aylward 105426b53f Formatting 2015-10-26 18:35:40 -04:00
John J. Aylward 7886c96204 Changes JSONArray for loops to use the new iterators. 2015-10-26 18:30:41 -04:00
John J. Aylward 91c6f09be8 Modifies XML output to be handled the same for a native java array as well as a JSONArray. 2015-10-26 18:17:37 -04:00
John J. Aylward 1b06a802cf makes params final 2015-10-12 14:54:30 -04:00
John J. Aylward 0e13241528 Expands javadoc 2015-10-12 14:53:03 -04:00
John J. Aylward e239e1967a Allows a custom message to be passed with a cause. 2015-10-12 14:52:17 -04:00
John J. Aylward ceba8e8c3d Fixes possible NPE 2015-10-12 14:25:18 -04:00
John J. Aylward 4e77383472 Properly overrides the Exception class. 2015-10-12 14:23:05 -04:00