You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-21Lines changed: 22 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,36 +1,34 @@
1
1
# java.util.json Backport for JDK 21+
2
2
3
-
Early access to the future`java.util.json` API - taken from OpenJDK sandbox July 2025.
3
+
Early access to the unstable`java.util.json` API - taken from OpenJDK sandbox July 2025.
4
4
5
-
## Project Vision
6
-
7
-
This project provides Java developers with early access to the future `java.util.json` API today, allowing code written against this API to migrate seamlessly when the official API is released.
8
-
## Current Status
5
+
## Back Port Project Goals
9
6
10
-
This code is derived from the official OpenJDK sandbox repository at commit [d22dc2ba89789041c3908cdaafadc1dcf8882ebf](https://github.com/openjdk/jdk-sandbox/commit/d22dc2ba89789041c3908cdaafadc1dcf8882ebf) (Mid July 2025 "Improve hash code spec wording").
7
+
-**✅Enable early adoption**: Let developers try the unstable Java JSON patterns today on JDK 21+
8
+
-**✅API compatibility over performance**: Focus on matching the emerging "batteries included" API design rather than competing with existing JSON libraries on speed.
9
+
-**✅Track any official solution** track any `java.util.json` with matching API updates to be a potential "unofficial backport".
10
+
-**✅Host Examples / Counter Examples** if anyone has any interest. GitHub wiki can be used for this if there is community interest.
11
11
12
-
The original proposal and design rationale can be found in the included PDF: [Towards a JSON API for the JDK.pdf](Towards%20a%20JSON%20API%20for%20the%20JDK.pdf)
12
+
## Non-Goals
13
13
14
-
## Back Port Project Goals
14
+
-**🛑Performance competition**: This backport is not intended to be the fastest JSON library. The JDK internal annotations that boost performance had to be removed.
15
+
-**🛑Feature additions**: No features beyond what's in the official sandbox/preview public API. Demos and example code are most welcome.
16
+
-**🛑Production optimization**: The final official implementation will have cutrent and future JVM-level optimizations unavailable to a backport on Java 21.
17
+
-**🛑API stability**: This backport may, or may not, track the official specification develops (only if folks find it useful).
18
+
-**🛑Advoocacy / Counter Advocacy**: This repo is not an endorsement of the proposed API nor a rejection of other solutions. Please only use the official Java email lists to debate the topic.
15
19
16
-
-**Enable early adoption**: Let developers use future Java JSON patterns today on JDK 21+
17
-
-**Smooth migration path**: Code written against this API should require less changes when migrating to the eventual official release
18
-
-**API compatibility over performance**: Focus on matching the emerging "batteries included" API design rather than competing with existing JSON libraries on speed
20
+
## Current Status
19
21
20
-
## Non-Goals
22
+
This code (as at July 2025) is derived from the official OpenJDK sandbox repository at commit [d22dc2ba89789041c3908cdaafadc1dcf8882ebf](https://github.com/openjdk/jdk-sandbox/commit/d22dc2ba89789041c3908cdaafadc1dcf8882ebf) (Mid July 2025 "Improve hash code spec wording").
21
23
22
-
-**Performance competition**: This is not intended to be the fastest JSON library the JDK internal annotations had to be removed.
23
-
-**Feature additions**: No features beyond what's in the official sandbox/preview.
24
-
-**Production optimization**: The final official implementation will have JVM-level optimizations unavailable to a backport on Java 21.
25
-
-**API stability**: This backport may evolve as the official specification develops (only if folks find it useful)
24
+
The original proposal and design rationale can be found in the included PDF: [Towards a JSON API for the JDK.pdf](Towards%20a%20JSON%20API%20for%20the%20JDK.pdf)
26
25
27
26
## Modifications
28
27
29
28
This is a simplified backport with the following changes from the original:
30
-
- Replaced StableValue optimizations with double-checked locking pattern
31
-
- Removed value-based class annotations
32
-
- Basic implementation without advanced performance optimizations
33
-
- Compatible with JDK 21+ instead of future JDK versions
29
+
- Replaced StableValue with double-checked locking pattern.
30
+
- Removed value-based class annotations.
31
+
- Compatible with JDK 21.
34
32
35
33
## Building
36
34
@@ -57,6 +55,7 @@ The API provides immutable JSON value types:
57
55
-`JsonNull` - JSON null
58
56
59
57
Parsing is done via the `Json` class:
58
+
60
59
```java
61
60
JsonValue value =Json.parse(jsonString);
62
61
```
@@ -66,6 +65,7 @@ JsonValue value = Json.parse(jsonString);
66
65
The `Json` class provides bidirectional conversion between `JsonValue` objects and standard Java types:
67
66
68
67
### Converting from Java Objects to JSON (`fromUntyped`)
0 commit comments