Lightweight JSON library for Java with no runtime dependencies.
- Parse and write JSON
BigDecimalnumbers- Object/array builder API
- POJO data binding
- Streaming / NDJSON
- JSON Pointer, Patch, and Merge Patch
gradle build
gradle testimport heehee.michael.json.*;
JsonValue json = Json.parse("""
{"name":"Michael","age":25,"tags":["java","json"]}
""");
String name = json.get("name").asString();
int age = json.get("age").asInt();
String tag = json.get("tags").get(0).asString();JsonObject json = Json.object()
.put("name", "Michael")
.put("age", 25)
.put("active", true);
String text = Json.stringify(json);
String pretty = Json.stringifyPretty(json);JsonMapper mapper = new JsonMapper();
JsonValue json = mapper.toJson(user);
User user = mapper.fromJson(json, User.class);try (JsonStreamReader reader = JsonStreamReader.open(Path.of("data.ndjson"))) {
reader.stream().forEach(System.out::println);
}JsonPatch patch = JsonPatch.fromJson("""
[{"op":"replace","path":"/name","value":"Michael"}]
""");
JsonValue result = patch.apply(json);