java.util.json
API from OpenJDK sandbox,
enabling developers to use future JSON API patterns today on JDK 21+.
<dependency>
<groupId>io.github.simbo1905.json</groupId>
<artifactId>java.util.json</artifactId>
<version>0.1.8</version>
</dependency>
import jdk.sandbox.java.util.json.*;
// Parse JSON
JsonValue value = Json.parse("{\"name\":\"Alice\",\"age\":30}");
JsonObject obj = (JsonObject) value;
// Access values
String name = ((JsonString) obj.members().get("name")).value();
int age = ((JsonNumber) obj.members().get("age")).toNumber().intValue();
java.util.json
// Domain model
record User(String name, String email, boolean active) {}
record Team(String teamName, List<User> members) {}
// Convert to JSON
Team team = new Team("Engineering", List.of(
new User("Alice", "alice@example.com", true),
new User("Bob", "bob@example.com", false)
));
JsonValue teamJson = Json.fromUntyped(Map.of(
"teamName", team.teamName(),
"members", team.members().stream()
.map(u -> Map.of(
"name", u.name(),
"email", u.email(),
"active", u.active()
))
.toList()
));
This code (as of 2025-09-04) is derived from the OpenJDK jdk-sandbox repository “json” branch at commit Produce path/col during path building. The API may evolve as the official specification develops.
Licensed under the GNU General Public License version 2 with Classpath exception, same as the OpenJDK project.