Commit Graph
24 Commits
Author SHA1 Message Date
John J. Aylward a2d3b59394 Implements unicode escaping similar to JSONObject.
* Removes deprecation on XML.stringToValue(). It now provides unescaping for strings to convert XML entities back into values.
* New unescape function to handle XML entities -> value conversion.
2016-09-22 12:38:06 -04:00
John J. Aylward 88f65c5bea Merge branch 'master' of github.com:stleary/JSON-java into NumberOutputFix
# Conflicts:
#	JSONObject.java
2016-08-26 11:32:35 -04:00
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 349a209df3 Merge remote-tracking branch 'upstream/master' into EnumCleanup 2016-08-15 10:25:27 -04:00
John J. Aylward 7851e9b2e8 revert back changes to Number support 2016-08-15 10:24:38 -04:00
John J. Aylward 91107e3e82 Adds support to JSONObject wrap and write methods to explicitly handle Enums.
The new way enums are handled is to always place the actual enum in the
JSONObject/JSONArray. When writing, we always write the actual "name"
of the enum, so even with a toString override on the enum class, the
value remains consistant and compatible with the optEnum/getEnum methods.

The constructor JSONObject(Object) functions the same way as before when
passing an enum and is consistent with other "value" types. For example,
when creating a JSONObject with Long, Boolean, BigDecimal as the constructor
parameter, the value will be treated as a "bean".
2016-08-11 12:22:31 -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