Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3e688af
Small test fixes.
eamonnmcmanus Sep 19, 2023
661114c
Generalize the logic to disallow nested objects and arrays as keys in…
eamonnmcmanus Sep 20, 2023
db0fde2
Add optJSONArray method to JSONObject with a default value
eedijs Sep 25, 2023
4e8231c
Merge pull request #770 from eamonnmcmanus/testfixes
stleary Sep 26, 2023
284a316
Add optJSONArray and optJSONObject methods to JSONArray with a defaul…
eedijs Sep 27, 2023
16967f3
Simplify the check for object keys that are themselves objects.
eamonnmcmanus Sep 27, 2023
dbb1131
Add more test cases for unquoted text in objects and arrays.
eamonnmcmanus Sep 28, 2023
eaa5611
Merge branch 'stleary:master' into complexkey
eamonnmcmanus Sep 28, 2023
ef68cdf
Merge pull request #773 from eedijs/master
stleary Sep 30, 2023
61bb60e
Removing excessive synchronization
mccartney Sep 30, 2023
ff921db
Junit 4.13.2
mccartney Sep 30, 2023
beb2fb5
Merge pull request #772 from eamonnmcmanus/complexkey
stleary Oct 1, 2023
1726b6c
Merge pull request #776 from mccartney/junit-4-13-2
stleary Oct 4, 2023
79af389
Merge pull request #774 from mccartney/removing-synchronized
stleary Oct 4, 2023
fe45fa9
Fix XMLTest on Windows
mureinik Oct 5, 2023
4c8cac2
Use System.lineSeparator()
mureinik Oct 5, 2023
1a38879
#653 - optLong vs getLong inconsistencies
rudrajyotib Oct 6, 2023
0e4a94d
fix failing test XML test on Windows machines
Madjosz Oct 4, 2023
c93014c
add validity check for JSONObject constructors
Madjosz Oct 4, 2023
bc09f90
Merge pull request #782 from mureinik/XMLTest-windows
stleary Oct 8, 2023
fb99c06
Merge branch 'master' into fix_xml_test
stleary Oct 8, 2023
776b5cc
Merge pull request #778 from Madjosz/fix_xml_test
stleary Oct 8, 2023
c4cd526
Merge pull request #779 from Madjosz/713_jsonobject_nonfinite
stleary Oct 8, 2023
d5277b1
Merge branch 'stleary:master' into master
rudrajyotib Oct 11, 2023
0cdc38a
#653 - review comments updated.
rudrajyotib Oct 11, 2023
56cb5f8
#653 - review comments updated.
rudrajyotib Oct 12, 2023
495cec9
Merge pull request #783 from rudrajyotib/master
stleary Oct 13, 2023
af5f780
update the docs for release 20231013
Oct 13, 2023
cca6d10
Merge pull request #792 from stleary/pre-release-20231013
stleary Oct 13, 2023
b180dbe
Reverting #761
Oct 13, 2023
f346203
Merge pull request #793 from stleary/revert-761
stleary Oct 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ JSON in Java [package org.json]

[![Maven Central](https://img.shields.io/maven-central/v/org.json/json.svg)](https://mvnrepository.com/artifact/org.json/json)

**[Click here if you just want the latest release jar file.](https://search.maven.org/remotecontent?filepath=org/json/json/20230618/json-20230618.jar)**
**[Click here if you just want the latest release jar file.](https://search.maven.org/remotecontent?filepath=org/json/json/20231013/json-20231013.jar)**


# Overview
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repositories {
}

dependencies {
testImplementation 'junit:junit:4.13.1'
testImplementation 'junit:junit:4.13.2'
testImplementation 'com.jayway.jsonpath:json-path:2.1.0'
testImplementation 'org.mockito:mockito-core:4.2.0'
}
Expand Down
2 changes: 2 additions & 0 deletions docs/RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ and artifactId "json". For example:
[https://search.maven.org/search?q=g:org.json%20AND%20a:json&core=gav](https://search.maven.org/search?q=g:org.json%20AND%20a:json&core=gav)

~~~
20231013 First release with minimum Java version 1.8. Recent commits, including fixes for CVE-2023-5072.

20230618 Final release with Java 1.6 compatibility. Future releases will require Java 1.8 or greater.

20230227 Fix for CVE-2022-45688 and recent commits
Expand Down
38 changes: 10 additions & 28 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230618</version>
<version>20231013</version>
<packaging>bundle</packaging>

<name>JSON in Java</name>
Expand All @@ -15,7 +15,7 @@
It also includes the capability to convert between JSON and XML, HTTP
headers, Cookies, and CDL.

This is a reference implementation. There is a large number of JSON packages
This is a reference implementation. There are a large number of JSON packages
in Java. Perhaps someday the Java community will standardize on one. Until
then, choose carefully.
</description>
Expand Down Expand Up @@ -57,7 +57,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -159,35 +159,17 @@
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
<version>1.0.0.Final</version>
<executions>
<execution>
<id>add-module-infos</id>
<phase>package</phase>
<goals>
<goal>add-module-info</goal>
</goals>
<configuration>
<jvmVersion>9</jvmVersion>
<module>
<moduleInfo>
<name>org.json</name>
<exports>
org.json;
</exports>
</moduleInfo>
</module>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.json</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
51 changes: 38 additions & 13 deletions src/main/java/org/json/JSONArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -924,30 +924,57 @@ public BigDecimal optBigDecimal(int index, BigDecimal defaultValue) {
}

/**
* Get the optional JSONArray associated with an index.
* Get the optional JSONArray associated with an index. Null is returned if
* there is no value at that index or if the value is not a JSONArray.
*
* @param index
* subscript
* @return A JSONArray value, or null if the index has no value, or if the
* value is not a JSONArray.
* The index must be between 0 and length() - 1.
* @return A JSONArray value.
*/
public JSONArray optJSONArray(int index) {
Object o = this.opt(index);
return o instanceof JSONArray ? (JSONArray) o : null;
return this.optJSONArray(index, null);
}

/**
* Get the optional JSONArray associated with an index. The defaultValue is returned if
* there is no value at that index or if the value is not a JSONArray.
*
* @param index
* The index must be between 0 and length() - 1.
* @param defaultValue
* The default.
* @return A JSONArray value.
*/
public JSONArray optJSONArray(int index, JSONArray defaultValue) {
Object object = this.opt(index);
return object instanceof JSONArray ? (JSONArray) object : defaultValue;
}

/**
* Get the optional JSONObject associated with an index. Null is returned if
* the key is not found, or null if the index has no value, or if the value
* is not a JSONObject.
* there is no value at that index or if the value is not a JSONObject.
*
* @param index
* The index must be between 0 and length() - 1.
* @return A JSONObject value.
*/
public JSONObject optJSONObject(int index) {
Object o = this.opt(index);
return o instanceof JSONObject ? (JSONObject) o : null;
return this.optJSONObject(index, null);
}

/**
* Get the optional JSONObject associated with an index. The defaultValue is returned if
* there is no value at that index or if the value is not a JSONObject.
*
* @param index
* The index must be between 0 and length() - 1.
* @param defaultValue
* The default.
* @return A JSONObject value.
*/
public JSONObject optJSONObject(int index, JSONObject defaultValue) {
Object object = this.opt(index);
return object instanceof JSONObject ? (JSONObject) object : defaultValue;
}

/**
Expand Down Expand Up @@ -1619,9 +1646,7 @@ public String toString() {
@SuppressWarnings("resource")
public String toString(int indentFactor) throws JSONException {
StringWriter sw = new StringWriter();
synchronized (sw.getBuffer()) {
return this.write(sw, indentFactor, 0).toString();
}
return this.write(sw, indentFactor, 0).toString();
}

/**
Expand Down
Loading