33 Commits

Author SHA1 Message Date
Sean Leary
771c82c4eb backing out recent changes to optLong, getLong. See #868 2024-02-24 13:07:51 -06:00
Sean Leary
5ddb8c3d35 cleanup-and-merge-tests: fix warnings, set gradlew permissions, enable unchecked warnings in maven 2023-12-30 16:30:19 -06:00
sk02241994
7701f21839 Adding comments 2023-12-24 11:39:26 +05:30
sk02241994
abea194120 Adding JSONParserConfiguration for configuring the depth of nested maps 2023-12-22 15:47:55 +05:30
sk02241994
6d811607dd Resolving issue #743
- Recursive depth issue found in JSONObject
- Recursive depth issue found in JSONArray
2023-12-22 15:47:54 +05:30
rudrajyoti biswas
98b79ae7bf #813 - moved number conversion related common changes to utility static method. 2023-10-23 19:16:25 +05:30
rudrajyoti biswas
1d0775cce7 Revert changes with feature and refactor together. 2023-10-19 10:28:11 +05:30
rudrajyoti biswas
7b2677ac5a #790 - Update XML with changes for string to number conversion.
Moved the code logic to a common utility to de-duplicate.
2023-10-14 10:05:36 +05:30
Grzegorz Olędzki
61bb60e752 Removing excessive synchronization 2023-09-30 21:36:11 +02:00
Edijs
284a316838 Add optJSONArray and optJSONObject methods to JSONArray with a default value 2023-09-27 19:30:45 +03:00
dburbrid
4951ec48c8 Renamed object methods from ...Obj to ...Object.
Added object method for optDoubleObject (returns Double vice double).
Added similar methods in JSONArray.
Added test methods.
2023-06-29 09:39:34 +01:00
stleary
89f6e7f6a6 Merge branch 'master' into update-copyright 2022-08-26 20:59:00 -05:00
stleary
6daabb43ab update-copyright - Replace copyright and license restrictions with Public Domain 2022-08-23 20:00:25 -05:00
Scott Paffrath
89f16ad0af Issue 682 JSONString similarity 2022-08-05 11:00:33 -07:00
John J. Aylward
a642329314 Updates value error messages to be consistent.
Provide both the type and value that failed conversion. Tries not to
"toString" large value types like Arrays or Maps. For those types it
will just output the type and not a value.
2022-03-21 12:48:25 -04:00
Liam Miller-Cushon
8ca8a80753 Fix some typos 2021-08-25 13:56:44 -07:00
stleary
c6089e53f5 Fixes Issue #611 JsonArray.similar() returns after number entry check 2021-07-18 19:53:23 -05:00
Ian Lovejoy
75894086e5 Fixed incorrect cast getting float from array
Added test for getting float from array
2021-04-27 19:03:35 -07:00
Stranck
c7130d577a Oops 2020-12-04 01:09:18 +01:00
Stranck
d85eea53bb Update JSONArray.java 2020-12-04 01:07:29 +01:00
Stranck
57ad94ef5e Added clear() methods to JSONObject and JSONArray 2020-12-04 00:49:21 +01:00
John J. Aylward
11e6b1af7e fixes issue #573 by added specific compare of numeric types 2020-11-19 18:55:49 -05:00
John J. Aylward
f35194bc1d Updates the addAll methods to have optional wrapping.
When called from the constructor, the individual items in the
collection/array are wrapped as done originally before the `putAll`
methods were added.

However this commit changes how `putAll` works. The items are no longer
wrapped in order to keep consistency with the other `put` methods.

However this can lead to inconsistencies with expectations. For example
code like this will create a mixed JSONArray, some items wrapped, others
not:

```java
SomeBean[] myArr = new SomeBean[]{ new SomeBean(1), new SomeBean(2) };
JSONArray jArr = new JSONArray(myArr); // these will be wrapped
// these will not be wrapped
jArr.putAll(new SomeBean[]{ new SomeBean(3), new SomeBean(4) });
```

For consistency, it would be recommended that the above code is changed
to look like 1 of 2 ways.

Option 1:
```Java
SomeBean[] myArr = new SomeBean[]{ new SomeBean(1), new SomeBean(2) };
JSONArray jArr = new JSONArray();
jArr.putAll(myArr); // will not be wrapped
// these will not be wrapped
jArr.putAll(new SomeBean[]{ new SomeBean(3), new SomeBean(4) });
// our jArr is now consistent.
```

Option 2:
```Java
SomeBean[] myArr = new SomeBean[]{ new SomeBean(1), new SomeBean(2) };
JSONArray jArr = new JSONArray(myArr); // these will be wrapped
// these will be wrapped
jArr.putAll(new JSONArray(new SomeBean[]{ new SomeBean(3), new
SomeBean(4) }));
// our jArr is now consistent.
```
2020-07-30 10:10:06 -04:00
John J. Aylward
5d828d2c0b update comments and increase speed of merging JSONArray objects 2020-07-30 10:10:06 -04:00
John J. Aylward
c175a9eb62 remove clone 2020-07-30 10:10:06 -04:00
John J. Aylward
3c9573cc3d update some javadoc 2020-07-30 10:10:06 -04:00
John J. Aylward
f37c2d67c5 Update for JSONArray.putAll methods
* Adds a copy constructor for JSONArray
* Updates the JSONArray.addAll(Object) method to be more lenient
* Adds support for JSONArray.putAll of generic Iterables
* Adds support for JSONArray.putAll of another JSONArray
2020-07-30 10:10:06 -04:00
Erik C. Thauvin
f1d354ce7b Increase array list capacity in addAll(collection) method to ensure it can hold additional elements. 2020-07-21 17:35:32 -07:00
Erik C. Thauvin
86e136afc9 Increase array list capacity in addAll method to ensure it can hold additional elements. 2020-07-21 17:11:24 -07:00
Erik C. Thauvin
aa0a5a7245 Added putAll(Collection) and putAll(Array) methods. 2020-06-16 14:55:16 -07:00
vivek
d088cf014e Development for stleary#516 completed with rebased repository
- Introduced JSONObject(int) constructor.
   - int > Initial capacity of the underlying data structure

- Test for new introduced JSONArray(int) constructor.
   1. Checked with input parameter: 0
   2. Checked with input parameter: positive number
   3. Checked with positive number input parameter and compared length
   4. If input parameter is negative number JSONException is thrown:
         JSONArray initial capacity cannot be negative.
2020-06-03 11:46:48 +02:00
stleary
2b0a8838ef gradle support 2020-05-22 11:17:44 -05:00
Benjamin Gehrels
74e4932cfc Transform the repository into standard maven format and merge the pom.xml of the release repo 2020-04-29 19:24:44 +02:00