230 Commits

Author SHA1 Message Date
Keaton
7915d8518f
Merge branch 'stleary:master' into feature-disable-whitespace-trim 2024-01-18 09:17:26 +02:00
Sean Leary
86bb0a1a02 cleanup-and-merge-tests: pull in unit tests from #809 2023-12-30 17:00:02 -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
ffd48afa42 Review comments 2023-12-23 10:53:54 +05:30
sk02241994
abea194120 Adding JSONParserConfiguration for configuring the depth of nested maps 2023-12-22 15:47:55 +05:30
sk02241994
dcac3bc18e Adding test case for nested json with depth of 999, 1000, 1001 2023-12-22 15:47:54 +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
Keaton Taylor
9ee10fdfc8 Merge remote-tracking branch 'origin/master' into feature-disable-whitespace-trim 2023-11-27 11:15:49 +02:00
Keaton Taylor
30f5b2de79 Add a config flag to disable whitespace trimming 2023-11-20 17:50:22 +02:00
Saiharshith Karuneegar Ramesh
1a61af8255 Fixed flaky tests in XMLTest.java 2023-11-13 13:25:30 -06:00
John J. Aylward
a3742acf74 Fixes #821
add ignore annotation to tests that may fail due to differences in machine resources and can't be controlled via the tests
2023-11-06 17:54:09 -05:00
rudrajyoti biswas
8ec822c575 #748 - PR comments - follow convention of configuration builder. 2023-10-28 07:36:31 +05:30
rudrajyoti biswas
c6ec2f0e4c #748 - close XML tag explicitly for empty tags with configuration. 2023-10-25 23:23:00 +05:30
Rudrajyoti Biswas
04a4c5a3ec
Merge branch 'stleary:master' into master 2023-10-21 12:29:31 +00:00
rudrajyoti biswas
2374766018 #790 - Update XML with changes for string to number conversion.
For now the code remains duplicated in JSON and XML parsers.
Unit test cases updated to comply with number expectations.
2023-10-19 14:07:53 +05:30
rudrajyoti biswas
1d0775cce7 Revert changes with feature and refactor together. 2023-10-19 10:28:11 +05:30
Sean Leary
d677a99f4e
Merge pull request #798 from hofi1/bugfix/fix-XML-flacky-test
fix: flakiness in org.json.junit.XMLTest#testIndentComplicatedJsonObjectWithArrayAndWithConfig
2023-10-17 13:52:29 -05:00
Sean Leary
e6d37c469d
Merge pull request #788 from hofi1/bugfix/fix-JSON-flakiness
Fix string compare unit tests
2023-10-17 13:51:40 -05:00
simonh5
4dfd779b1c fix: flakiness in org.json.junit.XMLTest#testIndentComplicatedJsonObjectWithArrayAndWithConfig 2023-10-14 17:21:06 -05:00
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
simonh5
29a7f4622d remove JSONAssert 2023-10-13 21:23:09 -05:00
simonh5
e4aa7f1308 fix: change from JSONAssert to checking the similarity of JSONObjects 2023-10-12 21:09:27 -05:00
rudrajyoti biswas
0cdc38ac24 #653 - review comments updated. 2023-10-12 00:53:36 +05:30
Rudrajyoti Biswas
d5277b126b
Merge branch 'stleary:master' into master 2023-10-11 19:17:21 +00:00
Simon Hofbauer
228598ca84
Merge pull request #6 from hofi1/bugfix/fix-flakyness-testToJSONObject_reversibility
fix: flakiness in JSONMLTest#testToJSONObject_reversibility
2023-10-10 18:20:20 -05:00
Sean Leary
c4cd526c53
Merge pull request #779 from Madjosz/713_jsonobject_nonfinite
add validity check for JSONObject constructors
2023-10-08 17:08:32 -05:00
Madjosz
c93014cb53 add validity check for JSONObject constructors
* fixes #713
* document JSONException in JavaDoc
* remove unused Comparable<T> boundary to reuse GenericBean in test
2023-10-07 09:38:54 +02:00
Madjosz
0e4a94d91d fix failing test XML test on Windows machines 2023-10-07 09:38:07 +02:00
rudrajyoti biswas
1a38879c90 #653 - optLong vs getLong inconsistencies
For exponential decimal conversion, number is not touched.
Leading zeros removed from numeric number strings before converting to number.
2023-10-06 21:34:00 +05:30
Sean Leary
beb2fb5706
Merge pull request #772 from eamonnmcmanus/complexkey
Disallow nested objects and arrays as keys in objects.
2023-10-01 11:04:40 -05:00
Sean Leary
ef68cdf810
Merge pull request #773 from eedijs/master
Add optJSONArray method to JSONObject with a default value
2023-09-30 11:47:01 -05:00
Éamonn McManus
eaa5611ba3
Merge branch 'stleary:master' into complexkey 2023-09-28 11:33:08 -07:00
Éamonn McManus
dbb113176b Add more test cases for unquoted text in objects and arrays. 2023-09-28 11:05:50 -07:00
Éamonn McManus
16967f322e Simplify the check for object keys that are themselves objects.
For object keys, we can just skip the part of `nextValue()` that parses values
that are objects or arrays. Then the existing logic for unquoted values will
already stop at `{` or `[`, and that will produce a `Missing value` exception.
2023-09-27 12:42:04 -07:00
Edijs
284a316838 Add optJSONArray and optJSONObject methods to JSONArray with a default value 2023-09-27 19:30:45 +03:00
Edijs
db0fde2a56 Add optJSONArray method to JSONObject with a default value 2023-09-25 20:31:58 +03:00
Éamonn McManus
661114c50d Generalize the logic to disallow nested objects and arrays as keys in objects.
Fixes #771.
2023-09-20 10:50:48 -07:00
simonh5
ca88454f1c fix: flakiness in org.json.junit.JSONObjectTest#valueToString 2023-09-19 14:28:06 -05:00
Éamonn McManus
3e688afc66 Small test fixes.
One test method was missing `@Test` so it was never run.

One test method used another test class as the base for finding a test
resource. While this works in practice with Maven, it is not strictly
right.
2023-09-19 07:38:13 -07:00
simonh5
becc1631e6 fix: flakiness in JSONMLTest#testToJSONObject_reversibility 2023-09-18 20:20:13 -05:00
Valentyn Kolesnikov
74cd73f97c Addressed compile warnings 2023-09-08 07:34:00 +03:00
dburbrid
3dd8f2ecd5 Correction of bug when compiling/testing on Windows: Issue537 file must be read as UTF-8 (Issue 745) 2023-08-28 19:03:40 +03:00
Valentyn Kolesnikov
bae0b0dac9 Updated mockito 2023-08-28 19:01:47 +03:00
Valentyn Kolesnikov
e563dbcaaa Setup java 8 as minimum version 2023-08-28 19:00:00 +03:00
Éamonn McManus
b6ff0db984 Fix indentation in test. 2023-08-01 13:49:59 -07:00
Éamonn McManus
c8a9e15a57 Don't skip past \0 when parsing JSON objects.
A better solution might be to use -1 instead 0 to represent EOF everywhere,
which of course means changing `char` variables to `int`. The solution here is
enough to solve the immediate problem, though.

Fixes #758.
2023-08-01 13:11:25 -07: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
dburbrid
3d524349a1 Correction of bug when compiling/testing on Windows: Issue537 file must be read as UTF-8 (Issue 745) 2023-06-26 09:33:03 +01:00
superMaaax
48fb5261fe Fixed Flaky Tests Caused by JSON permutations
###Description
Flaky Tests found using NonDex by running the commands -
mvn -pl . edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=org.json.junit.XMLTest#testIndentComplicatedJsonObject

mvn -pl . edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=org.json.junit.XMLTest#testIndentSimpleJsonArray

mvn -pl . edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=org.json.junit.XMLTest#testIndentSimpleJsonObject

The logged failure was-

[ERROR] Failures:
[ERROR] XMLTest.testIndentSimpleJsonObject:1193 expected:<...>
<employee>
<[married>true</married>
<name>sonoo</name>
<salary>56000</salary]>
</employee>
</Te...> but was:<...>
<employee>
<[name>sonoo</name>
<salary>56000</salary>
<married>true</married]>
</employee>
</Te...>

The issue is the same for all three tests, so here I only show the failure message for the third test (to reduce the length of the error message).

### Investigation

The tests fail with a comparison error while comparing an expected JSON String and the result from the value returned from XML.toString(). The toString function of XML makes no guarantees as to the iteration order of the attributes in the object. This makes the test outcome non-deterministic, and the test fails whenever the function returns a mismatch in order of the elements in the JSON String. To fix this, the expected and actual keys should be checked in a more deterministic way so that the assertions do not fail.

### Fix

Expected and Actual values can be converted into JSONObject and the similar function can be used to compare these objects. As this function compares the values inside the JSONObjects without needing order, the test becomes deterministic and ensures that the flakiness from the test is removed.

The PR does not introduce a breaking change.
2023-03-21 20:58:32 -05:00
HariBabu t
e1eabc9c27 JSONTokener implemented java.io.Closeable 2023-03-04 23:08:32 +08:00