atbash-json-smart
Small library capable of converting Java instances to JSON and back, for Java 8, 11 and 17 inspired on JSON Smart v2.
With the standardization of this functionality in JSON-B, it advised to use a JSON-B implementation unless you are outside a Jakarta runtime and want some small and fast JSON handling.
Requirements
Runs on JDK 8, JDK 11 ClassPath, and JDK 17 ClassPath.
Configuration
Add artifact to pom.xml file.
<dependency>
<groupId>be.atbash.json</groupId>
<artifactId>octopus-json-smart</artifactId>
<version>1.1.1</version>
</dependency>
Reading JSON
Converts the "<json>" string to instance of T.
T JSONValue.parse("<json>", Class<T>);
Converting to JSON
Converts the POJO T to a JSON String
String JSONValue.toJSONString(T);
Customizing JSON reading/creation
- Implement the JSONAware interface
- Define custom encoders and writers with @MappedBy and custom CustomJSONEncoder, CustomBeanJSONEncoder and/or Writer.
- Define a custom Encoder which also implement JSONEncoderBuilder interface to have a builder like pattern for encoding JSON to Java.
Extend CustomBeanBuilderJSONEncoder and define it as encoder at @MappedBy.