diff --git a/README.md b/README.md
index 994e7f675..5cc3bd451 100644
--- a/README.md
+++ b/README.md
@@ -9,8 +9,9 @@ JSON in Java [package org.json]
[](https://mvnrepository.com/artifact/org.json/json)
[](https://github.com/stleary/JSON-java/actions/workflows/pipeline.yml)
[](https://github.com/stleary/JSON-java/actions/workflows/codeql-analysis.yml)
+[](https://javadoc.io/doc/org.json/json)
-**[Click here if you just want the latest release jar file.](https://search.maven.org/remotecontent?filepath=org/json/json/20250517/json-20250517.jar)**
+**[Click here if you just want the latest release jar file.](https://search.maven.org/remotecontent?filepath=org/json/json/20251224/json-20251224.jar)**
# Overview
diff --git a/build.gradle b/build.gradle
index 6dcdca6fc..898f10dc7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -42,7 +42,7 @@ subprojects {
}
group = 'org.json'
-version = 'v20250517-SNAPSHOT'
+version = 'v20251224-SNAPSHOT'
description = 'JSON in Java'
sourceCompatibility = '1.8'
diff --git a/docs/RELEASES.md b/docs/RELEASES.md
index cd53bbe55..653e2bb8c 100644
--- a/docs/RELEASES.md
+++ b/docs/RELEASES.md
@@ -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)
~~~
+20251224 Records, fromJson(), and recent commits
+
20250517 Strict mode hardening and recent commits
20250107 Restore moditect in pom.xml
diff --git a/pom.xml b/pom.xml
index 81f5c3c2c..8d0881cbe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
org.json
json
- 20250517
+ 20251224
bundle
JSON in Java
diff --git a/src/main/java/org/json/XML.java b/src/main/java/org/json/XML.java
index 3eb948c77..e14bb34e9 100644
--- a/src/main/java/org/json/XML.java
+++ b/src/main/java/org/json/XML.java
@@ -9,6 +9,7 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Iterator;
+import java.util.NoSuchElementException;
/**
* This provides static methods to convert an XML text into a JSONObject, and to
@@ -80,7 +81,7 @@ private static Iterable codePointIterator(final String string) {
public Iterator iterator() {
return new Iterator() {
private int nextIndex = 0;
- private int length = string.length();
+ private final int length = string.length();
@Override
public boolean hasNext() {
@@ -89,6 +90,9 @@ public boolean hasNext() {
@Override
public Integer next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
int result = string.codePointAt(this.nextIndex);
this.nextIndex += Character.charCount(result);
return result;
diff --git a/src/test/java/org/json/junit/JSONObjectLocaleTest.java b/src/test/java/org/json/junit/JSONObjectLocaleTest.java
index 1cdaf743d..e1a9dd64e 100755
--- a/src/test/java/org/json/junit/JSONObjectLocaleTest.java
+++ b/src/test/java/org/json/junit/JSONObjectLocaleTest.java
@@ -36,25 +36,31 @@ public void jsonObjectByLocaleBean() {
MyLocaleBean myLocaleBean = new MyLocaleBean();
- /**
- * This is just the control case which happens when the locale.ROOT
- * lowercasing behavior is the same as the current locale.
- */
- Locale.setDefault(new Locale("en"));
- JSONObject jsonen = new JSONObject(myLocaleBean);
- assertEquals("expected size 2, found: " +jsonen.length(), 2, jsonen.length());
- assertEquals("expected jsonen[i] == beanI", "beanI", jsonen.getString("i"));
- assertEquals("expected jsonen[id] == beanId", "beanId", jsonen.getString("id"));
-
- /**
- * Without the JSON-Java change, these keys would be stored internally as
- * starting with the letter, 'ı' (dotless i), since the lowercasing of
- * the getI and getId keys would be specific to the Turkish locale.
- */
- Locale.setDefault(new Locale("tr"));
- JSONObject jsontr = new JSONObject(myLocaleBean);
- assertEquals("expected size 2, found: " +jsontr.length(), 2, jsontr.length());
- assertEquals("expected jsontr[i] == beanI", "beanI", jsontr.getString("i"));
- assertEquals("expected jsontr[id] == beanId", "beanId", jsontr.getString("id"));
+ // save and restore the current default locale, to avoid any side effects on other executions in the same JVM
+ Locale defaultLocale = Locale.getDefault();
+ try {
+ /**
+ * This is just the control case which happens when the locale.ROOT
+ * lowercasing behavior is the same as the current locale.
+ */
+ Locale.setDefault(new Locale("en"));
+ JSONObject jsonen = new JSONObject(myLocaleBean);
+ assertEquals("expected size 2, found: " +jsonen.length(), 2, jsonen.length());
+ assertEquals("expected jsonen[i] == beanI", "beanI", jsonen.getString("i"));
+ assertEquals("expected jsonen[id] == beanId", "beanId", jsonen.getString("id"));
+
+ /**
+ * Without the JSON-Java change, these keys would be stored internally as
+ * starting with the letter, 'ı' (dotless i), since the lowercasing of
+ * the getI and getId keys would be specific to the Turkish locale.
+ */
+ Locale.setDefault(new Locale("tr"));
+ JSONObject jsontr = new JSONObject(myLocaleBean);
+ assertEquals("expected size 2, found: " +jsontr.length(), 2, jsontr.length());
+ assertEquals("expected jsontr[i] == beanI", "beanI", jsontr.getString("i"));
+ assertEquals("expected jsontr[id] == beanId", "beanId", jsontr.getString("id"));
+ } finally {
+ Locale.setDefault(defaultLocale);
+ }
}
}
diff --git a/src/test/java/org/json/junit/JSONObjectTest.java b/src/test/java/org/json/junit/JSONObjectTest.java
index 7ca6093b7..5c1d1a2eb 100644
--- a/src/test/java/org/json/junit/JSONObjectTest.java
+++ b/src/test/java/org/json/junit/JSONObjectTest.java
@@ -3117,12 +3117,13 @@ public void testJSONWriterException() {
// test a more complex object
writer = new StringWriter();
- try {
- new JSONObject()
+
+ JSONObject object = new JSONObject()
.put("somethingElse", "a value")
.put("someKey", new JSONArray()
- .put(new JSONObject().put("key1", new BrokenToString())))
- .write(writer).toString();
+ .put(new JSONObject().put("key1", new BrokenToString())));
+ try {
+ object.write(writer).toString();
fail("Expected an exception, got a String value");
} catch (JSONException e) {
assertEquals("Unable to write JSONObject value for key: someKey", e.getMessage());
@@ -3133,17 +3134,18 @@ public void testJSONWriterException() {
writer.close();
} catch (Exception e) {}
}
-
+
// test a more slightly complex object
writer = new StringWriter();
- try {
- new JSONObject()
+
+ object = new JSONObject()
.put("somethingElse", "a value")
.put("someKey", new JSONArray()
.put(new JSONObject().put("key1", new BrokenToString()))
.put(12345)
- )
- .write(writer).toString();
+ );
+ try {
+ object.write(writer).toString();
fail("Expected an exception, got a String value");
} catch (JSONException e) {
assertEquals("Unable to write JSONObject value for key: someKey", e.getMessage());