Jakarta JSON Processing with Japanese Joy 📎
To use it in a standalone Maven project, declare the following dependencies:
<dependency>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.leadpony.joy</groupId>
<artifactId>joy-classic</artifactId>
<version>2.1.0</version>
</dependency>
Now you can start to process JSON, just using the Jakarta EE APIs:
import java.io.StringReader;
import org.junit.jupiter.api.Test;
import jakarta.json.Json;
public class JsonpWithJoyTest {
@Test
public void parseJSON() {
var expected = "joy";
var json = """
{"hello":"%s"}
""".formatted(expected);
try (var stringReader = new StringReader(json)){
var jsonObject = Json.createReader(stringReader).readObject();
var actual = jsonObject.getString("hello");
assertEquals(expected, actual);
}
}
}