SJson is a lightweight json parser for server side workloads. It tries to get optimized memory and performance with below goals.
- Represent Json in native format.
- No external dependencies
- Trust the validity of json documents
- It is just enough to say invalid, reasoning is optional
Note: This is not general purpose parser. This is specifically written for REST Client use case.
- Service to Service Communications in microservices
- Client SDK such as Elastic REST Client.
Include below in your pom.xml
<dependency>
<groupId>com.techatpark.sjson</groupId>
<artifactId>json-parser</artifactId>
<version>1.0.0</version>
<dependency>
Below is the code to read JSON as Java Object
Json json = new Json();
Object obj = json.read(new StringReader("{ \"abc\" : \"def\" }"));
Below VM Options should be added for JVM. This is required to calculate the size of the objects
-javaagent:<<PATH_TO_JAR>>/jamm-0.4.1.jar --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED
SJson was part of the tech talk series at Bangalore Opensource Java User Group. This will give an idea behind this work.
- Setup : https://www.youtube.com/watch?v=q_1H8ZJceA8
- Optimization: https://www.youtube.com/watch?v=XMRaLCRfvlQ
- Collection: https://www.youtube.com/watch?v=tMgy5PxPFQ4