Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

name: Build
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Dev Build

on:
push:
branches: [ develop ]
branches: [ "develop" ]
pull_request:
branches: [ develop ]
branches: [ "develop" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '21'
java-version: '24'
distribution: 'temurin'
cache: maven
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Code Quality Checks
run: ./mvnw -B jacoco:prepare-agent test jacoco:report -s $GITHUB_WORKSPACE/settings.xml --file pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Quality Check
run: mvn -B jacoco:prepare-agent install jacoco:report --file pom.xml
30 changes: 30 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI

on:
push:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '24'
distribution: 'temurin'
- name: Publish to GitHub Maven Repository
run: ./mvnw -DskipTests -Dcheckstyle.skip deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 3 additions & 2 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
57 changes: 27 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,48 @@

# SJson

SJson is a **lightweight tailer made json parser for server side workloads**. It tries to get optimized memory and performance with below goals.
> **SJson** is a lightweight, high-performance JSON parser built for server-side Java. Designed for REST APIs and microservices, it delivers faster parsing with lower memory usage using native Java structures.

## Design Goals
## Why Use SJson?

1. Optimized for Serialization, Deserialization and validation.
2. Represent Json in native java format.
3. No external dependencies
4. Trust the validity of json documents. It is just enough to say invalid, reasoning is optional
5. Utilize latest java features
- Optimized for fast serialization & deserialization
- No external dependencies. Uses native Java types (`Map`, `List`, etc.)
- Assumes valid JSON (minimal validation overhead)
- Clean, modern, and extendable Java code

**Note:** This is **not** general purpose parser. This is specifically written for REST API use cases.
### Use cases

1. Service to Service Communications in microservices
2. Client SDK such as Elastic REST Client.
- **Microservices:** Service-to-service communication
- **Client SDKs:** Lightweight JSON processing (e.g., Elastic clients)
- **Data Engineering:** ETL pipelines, streaming ingestion, compact intermediate JSON parsing

## Usage

Include below in your pom.xml
Add dependency to your project

### Maven
```xml
<dependency>
<groupId>com.techatpark.sjson</groupId>
<artifactId>json-parser</artifactId>
<version>1.0.0</version>
<dependency>
<groupId>com.techatpark.sjson</groupId>
<artifactId>json-parser</artifactId>
<version>{{version}}</version>
</dependency>
```

To read JSON as Java Object

```java
Json json = Json;
Object obj = json.read(new StringReader("{ \"abc\" : \"def\" }"));
### Gradle
```groovy
implementation 'com.techatpark.sjson:json-parser:{{version}}'
```

## Development
You can now perform serialization & deserialization

Below VM Options should be added for JVM. This is required to calculate the size of the objects
```java
Object obj = Json.parse(Reader.of("{ \"abc\" : \"def\" }")); // Map<String, Object>

```shell
-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
String jsonString = Json.stringify(obj);
```
## How it works

SJson was part of the tech talk series at Bangalore Opensource Java User Group. This will give an idea behind this work.
## Reference

1. Setup : https://www.youtube.com/watch?v=q_1H8ZJceA8
2. Optimization: https://www.youtube.com/watch?v=XMRaLCRfvlQ
3. Collection: https://www.youtube.com/watch?v=tMgy5PxPFQ4
- https://www.youtube.com/watch?v=NSzRK8f7EX0&pp=ygUSSlNPTiBBUEkgQ29yZSBKYXZh
- https://www.youtube.com/watch?v=W8k9ZCrsphc&t=448s
- https://www.youtube.com/watch?v=R8Xubleffr8
Loading