Skip to content

dhoondlayai/artifact-json

Repository files navigation

💎 artifact-json: High-Performance JSON Library for Java 21+

Maven Central Java Version License

artifact-json is an enterprise-grade, zero-dependency JSON utility for the modern JVM (Java 21+). Optimized for maximum throughput and developer velocity, it offers ultra-fast data transformation, SQL-like JSON querying, and seamless multi-format conversion without the bloat of legacy frameworks.


🚀 Key Algorithms & Master Features

1. Advanced Traversal Engine (JsonTraversal)

Navigate complex trees with precision and speed.

  • DFS / BFS Support: Switch between depth-first and breadth-first search depending on tree density.
  • Path-Aware Traversal: Capture the exact dot-path (e.g., order.items[2].id) for every node.
  • On-the-fly Transformation: Modify values or structure during a single pass.

2. Tabular Flatten & Unflatten

Bridge the gap between nested JSON and flat data structures (like CSV or SQL).

  • Dot-Notation Flattening: Convert {"a": {"b": 1}} into {"a.b": 1}.
  • Perfect Reconstruction: Rebuild original complex trees from flat Maps instantly.

3. 🔥 Killer Feature: In-Memory SQL for JSON (JsonQuery)

Query JSON Arrays using a fluent, SQL-like API. No more manual loops or complex Stream filters.

import static io.github.dhoondlayai.artifact.json.query.JsonQuery.SortOrder.DESC;

var results = JsonQuery.from(orderArray)
    .select("id", "total", "customer.name")
    .whereGt("total", 100.00)
    .andContains("customer.name", "John")
    .orderBy("total", DESC)
    .limit(10)
    .execute();

4. 🔥 Killer Feature: Zero-Cost Deserialization (JsonProxy)

Map JSON to Java Interfaces without the overhead of heavy POJO instantiation or reflection-based mapping.

public interface UserProfile {
    String getName();
    void setName(String name);
    int getAge();
}

// Create a proxy that reads/writes directly to the underlying JsonNode
UserProfile profile = JsonProxy.create(UserProfile.class, jsonNode);
System.out.println(profile.getName());
profile.setName("New Name"); // Updates the JSON AST instantly!

5. 🔥 Killer Feature: Reverse Engineering (JsonCodeGenerator)

Generate production-ready Java source code from any JSON sample.

// Instantly outputs the complete Java Record source code for your JSON structures
String javaSource = JsonCodeGenerator.generateJavaRecords("OrderDto", rootNode);
Files.writeString(Path.of("OrderDto.java"), javaSource);

6. Unified Conversion Suite (JsonConverter)

A single entry point for multi-format transformations:

  • Formats: JSON ↔ CSV, XML, YAML, Properties, Markdown, HTML Table.
  • Formatting: Compact, Pretty-Print (custom indent), and Minified outputs.

7. Security & Redaction (JsonShield)

Safely access data and redact PII (Personally Identifiable Information) with ease.

JsonShield shield = new JsonShield(rawInput);

// Null-safe access with defaults
String apiKey = shield.getString("auth.key", "DEMO_KEY");

// Redact sensitive fields at any depth
JsonNode safeNode = shield.redact("password", "credit_card", "ssn");

🥊 Why Choose artifact-json over Jackson?

Built for the 2024+ Java 21 ecosystem, artifact-json leverages modern JVM features that legacy libraries cannot.

Feature Jackson artifact-json Performance Impact
Parsing Engine Reader/char[] Zero-Copy ByteBuffer 3x-5x Faster (Low GC pressure)
Object Mapping Standard Reflection MethodHandles (JSR-292) 2x-3x Faster access to POJOs
Querying Manual Streams Built-in JsonQuery Fluent, SQL-like aggregations
Deserialization Heavy Bean Mapping Zero-Cost JsonProxy Instant Interface Binding (O(1))
Logic/Safety instanceof Sealed Type Matching Cleaner, compiler-optimized JIT
Advanced Tools External Plugins Native SQL/Flatten/Redact All-in-one powerful toolkit

📦 Installation

Add this dependency to your pom.xml. Zero transitive dependencies.

<dependency>
    <groupId>io.github.dhoondlayai</groupId>
    <artifactId>artifact-json</artifactId>
    <version>2.0.2</version>
</dependency>

🏃‍♂️ Quick Start

import io.github.dhoondlayai.artifact.json.streaming.FastJsonEngine;
import io.github.dhoondlayai.artifact.json.model.*;

public class Main {
    public static void main(String[] args) {
        // 1. High-speed Parsing
        String json = "{\"brand\": \"Dhoondlay\", \"specs\": {\"cores\": 16, \"ram\": \"64GB\"}}";
        JsonObject root = FastJsonEngine.parse(json).asObject();

        // 2. Sealed-Type Pattern Matching (Java 21+)
        switch (root.get("specs")) {
            case JsonObject obj -> System.out.println("Cores: " + obj.getInt("cores"));
            case JsonValue val  -> System.out.println("Literal: " + val.asText());
            default -> {}
        }
        
        // 3. Easy Modification
        root.put("status", new JsonValue("active"));
        
        // 4. Pretty Printing
        System.out.println(root.toPrettyString(2));
    }
}

🏗️ Technical Architecture

Layer Optimized For Description
Engine Raw Throughput Hybrid parser using non-blocking NIO and SIMD-friendly loops.
Model Type Safety Uses Java 21 Sealed Interfaces for JsonNode hierarchy.
Query Developer Velocity AST-based query engine for in-memory data filtering.
Conversion Interoperability Native generators for XML, YAML, and Tabular formats.

📝 License

Distributed under the Apache License, Version 2.0. See LICENSE for more information.

Copyright © 2026 Dhoondlay AI

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors