Skip to content

Commit

Permalink
change(#871-strictMode): cleanup
Browse files Browse the repository at this point in the history
chore: removed PII from json sample
chore: JSONParserConfiguration.java cleanup
chore: JSONTokener.java nextValue partial rollback
  • Loading branch information
rikkarth committed Apr 7, 2024
1 parent d92d62a commit 3200275
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 76 deletions.
5 changes: 0 additions & 5 deletions src/main/java/org/json/JSONParserConfiguration.java
Expand Up @@ -23,11 +23,6 @@ public class JSONParserConfiguration extends ParserConfiguration {
*/
private boolean strictMode;

/**
* Allows Single Quotes when strictMode is true. Has no effect if strictMode is false.
*/
private boolean allowSingleQuotes;

/**
* Configuration with the default values.
*/
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/org/json/JSONTokener.java
Expand Up @@ -422,7 +422,7 @@ public Object nextValue() throws JSONException {
* Get the next value. The value can be a Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the
* JSONObject.NULL object. The strictMode parameter controls the behavior of the method when parsing the value.
*
* @param jsonParserConfiguration which carries options such as strictMode and allowSingleQuotes, these methods will
* @param jsonParserConfiguration which carries options such as strictMode, these methods will
* strictly adhere to the JSON syntax, throwing a JSONException for any deviations.
* @return An object.
* @throws JSONException If syntax error.
Expand All @@ -432,10 +432,18 @@ public Object nextValue(JSONParserConfiguration jsonParserConfiguration) throws
switch (c) {
case '{':
this.back();
return getJsonObject(jsonParserConfiguration);
try {
return new JSONObject(this, jsonParserConfiguration);
} catch (StackOverflowError e) {
throw new JSONException("JSON Array or Object depth too large to process.", e);
}
case '[':
this.back();
return getJsonArray();
try {
return new JSONArray(this);
} catch (StackOverflowError e) {
throw new JSONException("JSON Array or Object depth too large to process.", e);
}
default:
return nextSimpleValue(c, jsonParserConfiguration);
}
Expand All @@ -445,7 +453,7 @@ public Object nextValue(JSONParserConfiguration jsonParserConfiguration) throws
* This method is used to get a JSONObject from the JSONTokener. The strictMode parameter controls the behavior of
* the method when parsing the JSONObject.
*
* @param jsonParserConfiguration which carries options such as strictMode and allowSingleQuotes, these methods will
* @param jsonParserConfiguration which carries options such as strictMode, these methods will
* strictly adhere to the JSON syntax, throwing a JSONException for any deviations.
* deviations.
* @return A JSONObject which is the next value in the JSONTokener.
Expand Down
134 changes: 67 additions & 67 deletions src/test/resources/compliantJsonArray.json
Expand Up @@ -5,15 +5,15 @@
"guid": "441331fb-84d1-4873-a649-3814621a0370",
"isActive": true,
"balance": "$2,691.63",
"picture": "http://placehold.it/32x32",
"picture": "http://example.abc/32x32",
"age": 26,
"eyeColor": "blue",
"name": "Susie Estes",
"name": "abc",
"gender": "female",
"company": "ZENTURY",
"email": "susieestes@zentury.com",
"phone": "+1 (853) 428-2292",
"address": "424 Hewes Street, Grahamtown, Tennessee, 8138",
"company": "example",
"email": "abc@def.com",
"phone": "+1 (123) 456-7890",
"address": "123 Main St",
"about": "Laborum magna tempor officia irure cillum nulla incididunt Lorem dolor veniam elit cupidatat amet. Veniam veniam exercitation nulla consectetur officia esse ex sunt nulla nisi ea cillum nisi reprehenderit. Qui aliquip reprehenderit aliqua aliquip aliquip anim sit magna nostrud dolore veniam velit elit aliquip.\r\n",
"registered": "2016-07-22T03:18:11 -01:00",
"latitude": -21.544934,
Expand All @@ -30,18 +30,18 @@
"friends": [
{
"id": 0,
"name": "Simon Garrett"
"name": "abc def"
},
{
"id": 1,
"name": "Conrad Moon"
"name": "ghi jkl"
},
{
"id": 2,
"name": "Mccall Rosario"
"name": "mno pqr"
}
],
"greeting": "Hello, Susie Estes! You have 10 unread messages.",
"greeting": "Hello, abc! You have 10 unread messages.",
"favoriteFruit": "banana"
},
{
Expand All @@ -53,12 +53,12 @@
"picture": "http://placehold.it/32x32",
"age": 27,
"eyeColor": "green",
"name": "Irma Greer",
"name": "def",
"gender": "female",
"company": "ANIVET",
"email": "irmagreer@anivet.com",
"phone": "+1 (936) 539-2196",
"address": "285 Roebling Street, Hardyville, Hawaii, 8410",
"company": "sample",
"email": "def@abc.com",
"phone": "+1 (123) 456-78910",
"address": "1234 Main St",
"about": "Ea id cupidatat eiusmod culpa. Nulla consequat esse elit enim et pariatur eiusmod ipsum. Consequat eu non reprehenderit in.\r\n",
"registered": "2015-04-06T07:54:22 -01:00",
"latitude": 83.512347,
Expand All @@ -75,18 +75,18 @@
"friends": [
{
"id": 0,
"name": "Terri Morrison"
"name": "sample example"
},
{
"id": 1,
"name": "Foley Turner"
"name": "test name"
},
{
"id": 2,
"name": "Leila Brewer"
"name": "aaa aaaa"
}
],
"greeting": "Hello, Irma Greer! You have 7 unread messages.",
"greeting": "Hello, test! You have 7 unread messages.",
"favoriteFruit": "apple"
},
{
Expand All @@ -98,12 +98,12 @@
"picture": "http://placehold.it/32x32",
"age": 32,
"eyeColor": "green",
"name": "Rebecca Garner",
"name": "test",
"gender": "female",
"company": "OCEANICA",
"email": "rebeccagarner@oceanica.com",
"phone": "+1 (868) 551-3810",
"address": "425 Navy Walk, Spokane, Vermont, 7439",
"company": "test",
"email": "test@test.com",
"phone": "+1 (123) 456-7890",
"address": "123 Main St",
"about": "Mollit officia adipisicing ex nisi non Lorem sunt quis est. Irure exercitation duis ipsum qui ullamco eu ea commodo occaecat minim proident. Incididunt nostrud ex cupidatat eiusmod mollit anim irure culpa. Labore voluptate voluptate labore nisi sit eu. Dolor sit proident velit dolor deserunt labore sit ipsum incididunt eiusmod reprehenderit voluptate. Duis anim velit officia laboris consequat officia dolor sint dolor nisi ex.\r\n",
"registered": "2021-11-02T12:50:05 -00:00",
"latitude": -82.969939,
Expand All @@ -120,18 +120,18 @@
"friends": [
{
"id": 0,
"name": "Cox Trujillo"
"name": "test"
},
{
"id": 1,
"name": "Stanton Wilcox"
"name": "sample"
},
{
"id": 2,
"name": "Dolores Cooper"
"name": "example"
}
],
"greeting": "Hello, Rebecca Garner! You have 1 unread messages.",
"greeting": "Hello, test! You have 1 unread messages.",
"favoriteFruit": "strawberry"
},
{
Expand All @@ -143,12 +143,12 @@
"picture": "http://placehold.it/32x32",
"age": 35,
"eyeColor": "brown",
"name": "Foster Pratt",
"name": "another test",
"gender": "male",
"company": "COMTEST",
"email": "fosterpratt@comtest.com",
"phone": "+1 (829) 400-3497",
"address": "390 Montague Street, Sandston, Wyoming, 9116",
"company": "TEST",
"email": "anothertest@anothertest.com",
"phone": "+1 (321) 987-6543",
"address": "123 Example Main St",
"about": "Do proident consectetur minim quis. In adipisicing culpa Lorem fugiat cillum exercitation velit velit. Non voluptate laboris deserunt veniam et sint consectetur irure aliqua quis eiusmod consectetur elit id. Ex sint do anim Lorem excepteur eu nulla.\r\n",
"registered": "2020-06-25T04:55:25 -01:00",
"latitude": 63.614955,
Expand All @@ -165,18 +165,18 @@
"friends": [
{
"id": 0,
"name": "Savage Combs"
"name": "test"
},
{
"id": 1,
"name": "Cecelia Kemp"
"name": "sample"
},
{
"id": 2,
"name": "Priscilla Stephenson"
"name": "example"
}
],
"greeting": "Hello, Foster Pratt! You have 5 unread messages.",
"greeting": "Hello, another test! You have 5 unread messages.",
"favoriteFruit": "apple"
},
{
Expand All @@ -185,15 +185,15 @@
"guid": "2c3e5115-758d-468e-99c5-c9afa26e1f9f",
"isActive": true,
"balance": "$1,047.20",
"picture": "http://placehold.it/32x32",
"picture": "http://test.it/32x32",
"age": 30,
"eyeColor": "green",
"name": "Willie Wallace",
"name": "Test Name",
"gender": "female",
"company": "KNEEDLES",
"email": "williewallace@kneedles.com",
"phone": "+1 (816) 510-2695",
"address": "411 Dunne Place, Rosewood, Iowa, 283",
"company": "test",
"email": "testname@testname.com",
"phone": "+1 (999) 999-9999",
"address": "999 Test Main St",
"about": "Voluptate exercitation tempor consectetur velit magna ea occaecat cupidatat consectetur anim aute. Aliquip est aute ipsum laboris non irure qui consectetur tempor quis do ea Lorem. Cupidatat exercitation ad culpa aliqua amet commodo mollit reprehenderit exercitation adipisicing amet et laborum pariatur.\r\n",
"registered": "2023-01-19T02:43:18 -00:00",
"latitude": 14.15208,
Expand All @@ -210,18 +210,18 @@
"friends": [
{
"id": 0,
"name": "Burks Lowe"
"name": "test"
},
{
"id": 1,
"name": "Ray Sanchez"
"name": "sample"
},
{
"id": 2,
"name": "Tasha Weiss"
"name": "example"
}
],
"greeting": "Hello, Willie Wallace! You have 6 unread messages.",
"greeting": "Hello, test! You have 6 unread messages.",
"favoriteFruit": "apple"
},
{
Expand All @@ -230,15 +230,15 @@
"guid": "816cda74-5d4b-498f-9724-20f340d5f5bf",
"isActive": false,
"balance": "$2,628.74",
"picture": "http://placehold.it/32x32",
"picture": "http://testing.it/32x32",
"age": 28,
"eyeColor": "green",
"name": "Pearl Aguilar",
"name": "Testing",
"gender": "female",
"company": "TELEPARK",
"email": "pearlaguilar@telepark.com",
"phone": "+1 (801) 427-2087",
"address": "633 Highlawn Avenue, Defiance, Illinois, 2118",
"company": "test",
"email": "testing@testing.com",
"phone": "+1 (888) 888-8888",
"address": "123 Main St",
"about": "Cupidatat non ut nulla qui excepteur in minim non et nulla fugiat. Dolor quis laborum occaecat veniam dolor ullamco deserunt amet veniam dolor quis proident tempor laboris. In cillum duis ut quis. Aliqua cupidatat magna proident velit tempor veniam et consequat laborum ex dolore qui. Incididunt deserunt magna minim Lorem consectetur.\r\n",
"registered": "2017-10-14T11:14:08 -01:00",
"latitude": -5.345728,
Expand All @@ -255,18 +255,18 @@
"friends": [
{
"id": 0,
"name": "Edwards Wolf"
"name": "test"
},
{
"id": 1,
"name": "Hunter Fitzgerald"
"name": "sample"
},
{
"id": 2,
"name": "Valencia Norton"
"name": "example"
}
],
"greeting": "Hello, Pearl Aguilar! You have 2 unread messages.",
"greeting": "Hello, testing! You have 2 unread messages.",
"favoriteFruit": "strawberry"
},
{
Expand All @@ -275,15 +275,15 @@
"guid": "4ee550bc-0920-4104-b3ce-ebf9db6a803f",
"isActive": true,
"balance": "$1,709.31",
"picture": "http://placehold.it/32x32",
"picture": "http://sample.it/32x32",
"age": 31,
"eyeColor": "blue",
"name": "Tanisha Pacheco",
"name": "Sample Name",
"gender": "female",
"company": "VISUALIX",
"email": "tanishapacheco@visualix.com",
"phone": "+1 (867) 577-2549",
"address": "466 Coleridge Street, Dotsero, Delaware, 8574",
"company": "Sample",
"email": "sample@sample.com",
"phone": "+1 (777) 777-7777",
"address": "123 Main St",
"about": "Lorem ex proident ipsum ullamco velit sit nisi eiusmod cillum. Id tempor irure culpa nisi sit non qui veniam non ut. Aliquip reprehenderit excepteur mollit quis excepteur ex sit. Quis do eu veniam do ullamco occaecat eu cupidatat nisi laborum tempor minim fugiat pariatur. Ex in nulla ex velit.\r\n",
"registered": "2019-04-08T03:54:36 -01:00",
"latitude": -70.660321,
Expand All @@ -300,18 +300,18 @@
"friends": [
{
"id": 0,
"name": "Carter Galloway"
"name": "Test"
},
{
"id": 1,
"name": "Moody Cameron"
"name": "Sample"
},
{
"id": 2,
"name": "June Gillespie"
"name": "Example"
}
],
"greeting": "Hello, Tanisha Pacheco! You have 6 unread messages.",
"greeting": "Hello, Sample! You have 6 unread messages.",
"favoriteFruit": "apple"
}
]

0 comments on commit 3200275

Please sign in to comment.