1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 07:50:52 -07:00
Commit graph

74 commits

Author SHA1 Message Date
John J. Aylward
a7f8ff24df correct string check for JSONObject optBigDecimal and optBigInteger 2017-05-18 14:41:42 -04:00
John J. Aylward
1ab5260a7a * Adds methods getNUmber and getFloat to JSONArray and JSONObject
* Extracts the stringToNumber logic that the optNumber method uses to reuse it between classes
* Fixes -0 issue with optNumber/getNumber
2017-05-18 14:24:34 -04:00
John J. Aylward
c28a2bdf39 * reverts changes to getDouble and related optDouble and optFloat
* Updates optNumber to be smarter about which object it uses to parse strings
2017-05-18 13:07:32 -04:00
John J. Aylward
382f62e781 * Prevent exceptions in cases where the value is not a string.
* Don't call toString when we know it's a string, just cast
2017-05-18 11:41:51 -04:00
John J. Aylward
0c7bd725a6 fixes for javadoc 2017-05-17 11:34:37 -04:00
John J. Aylward
fcdb8671b2 grr, forgot to save changes on last commit 2017-05-17 11:32:44 -04:00
John J. Aylward
c46774cf13 * Update opt* methods for JSONArray
* Add support to JSONArray and JSONObject to optionally get raw number values
* Add support to JSONArray and JSONObject to optionally get float values
2017-05-17 11:29:26 -04:00
John J. Aylward
bd4b180f4e Support for float to BigDecimal in optBigDecimal 2017-05-17 10:51:06 -04:00
John J. Aylward
a8d4e4734f adjustments to opt methods in reference to https://github.com/stleary/JSON-java/issues/334 2017-05-16 19:38:01 -04:00
alessandro rao
9e0fc5e680 Allow user to invoke query and optQuery ,with a JSONPointer,directly
from JSONArray or JSONObject
2017-02-25 13:27:50 +01:00
John J. Aylward
eb806f4c14 make sure locale independent data is not upper/lowercased incorrectly. See #315 2017-02-10 10:07:28 -05: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
Sean Leary
7232a95c0b Update JSONObject.java
Fixed some typos committed in #249, since reverted, tracking issue is #263
2016-08-15 01:58:54 -05: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
Sean Leary
45a7decba4 Revert "reduces the use of unnecessary exceptions" 2016-08-09 14:22:06 -05:00
Nils Faupel
3890bfae52 reduce the use of unnecessary exceptions 2016-07-19 19:59:30 +02:00
Nils Faupel
abf2963bbe Revert "reduces the use of unnecessary exceptions"
This reverts commit 7627d40d10.
2016-07-19 19:00:42 +02:00
Simulant
7627d40d10 reduces the use of unnecessary exceptions 2016-07-08 22:17:05 +02:00
Sean Leary
612dafc750 Update JSONObject.java 2016-05-20 21:10:17 -05:00
Sean Leary
b2bde1f468 Merge pull request #234 from erosb/master
fixing stleary/JSON-Java#233
2016-05-20 21:03:06 -05:00
Bence Erős
56be31e7a8 fixing stleary/JSON-Java#233 2016-05-16 14:53:34 +02:00
stleary
4a458a9f1c add timestamps to recent commits, javadocs for JSONObject, JSONArray queryFrom() methods 2016-05-14 09:22:18 -05:00
Sean Leary
8a72509e6e Merge pull request #222 from erosb/master
JSON Pointer implementation
2016-05-13 22:46:52 -05:00
Sean Leary
cad23423ab Update JSONObject.java
Forgot to update date of last change
2016-05-02 22:11:20 -05:00
stleary
1ca8933a8f fix to compile with 1.6.0_45 2016-04-28 22:12:16 -05:00
Bence Erős
45bd72c15d added JSONObject#query() and JSONPointer#query() methods 2016-04-26 23:48:14 +02:00
Sean Leary
25a87975be Update date of merge. 2016-03-05 15:20:20 -06:00
Joe Ferner
f024b52108 Adds JSONArray toList method and JSONObject toMap method 2016-02-27 11:20:25 -05:00
skreutzer
60349ece54 Java 1.6 compatibility. 2016-02-08 23:30:27 -05:00
Sean Leary
93c79ca566 Version date 2016-01-30 15:44:41 -06: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
stleary
8688494876 change to public, write(writer, indentfactor, indent) 2015-12-23 19:53:30 -06:00
Siyuan Ren
23cf659730 Remove executable permission bit from file mode 2015-12-09 09:50:59 +08:00
Sean Leary
39e3ccc671 Update version
Update version after merge of https://github.com/douglascrockford/JSON-java/pull/179
2015-12-05 20:14:15 -06:00
Andrew Fletcher
cadba9400c Update JavaDoc for JSONObject Constructors
Two JSONObject constructors incorrectly specify a @throws JSONException
tag in the JavaDoc for those constructors. Remove the relevant JavaDoc.
2015-12-02 10:49:54 -08:00
Sean Leary
33ae025e78 Update JSONObject.java
Update version for https://github.com/douglascrockford/JSON-java/pull/153
2015-10-29 18:24:46 -05:00
Lukas Treyer
5ddc515679 removed 6 unnecessary @SuppressWarnings("unchecked") annotations. 2015-10-12 23:52:14 +02:00
Lukas Treyer
25b5aa7ef2 changed Map<String, ?> method parameters to Map<?,?>
changed Iterator to foreach loop in JSONArray ctor
JSONArray(Collection<?> collection) and JSONObject ctor
JSONObject(Map<?,?> map)
2015-10-11 12:21:12 +02:00
Lukas Treyer
409eb9f292 changed all method signatures containing collections and maps to accept
wildcard generic types, e.g. Collection<?> instead of
Collection<Object>. This was proposed by other pull requests (#111,
#112) already. Consider this commit as merge with #111 and #112.

JSONArray:
	- put(Collection<?> value) {...}
	- put(Map<String, ?> value) {...}
	- put(int index, Collection<?> value) throws JSONException {...}
	- put(int index, Map<String, ?> value) throws JSONException {...}

JSONObject:
	- put(String key, Collection<?> value) throws JSONException {...}
	- put(String key, Map<String, ?> value) throws JSONException {...}


Changed all code affected by new JSONObject and JSONArray constructors:
	
JSONObject:
	- valueToString(Object value) throws JSONException {
		- value instanceof Map
		- value instanceof Collection
	  }
	- wrap(Object object) {
		- value instanceof Map
		- value instanceof Collection
	  }
	- writeValue(Writer writer, Object value,
			 int indentFactor, int indent){
        - value instanceof Map
        - value instanceof Collection
      }
2015-10-11 11:20:08 +02:00
Lukas Treyer
0afd26623c JSONObject and JSONArray initialization:
JSONObject(Map<String, ?> map) allows to initialize the JSONObject with
a Map<String, String>

JSONArray(Collection<?> collection) allows to initialize a JSONArray
with a Collection<JSONObject>
2015-10-04 23:17:30 +02:00
stleary
5fc22e32a8 fix edit dates for enum support 2015-07-22 20:18:30 -05:00
stleary
9785b4ff0b enum support 2015-07-22 20:16:02 -05:00
stleary
ca3001629a latest 2015-07-22 20:11:07 -05:00
stleary
71d9ad2b99 update version dates 2015-07-06 22:27:10 -05:00
stleary
474f285cc8 Merge branch 'big-numbers' of https://github.com/douglascrockford/JSON-Java into local-big-numbers 2015-07-03 22:05:05 -05:00