Skip to content
dhis2Public

About

A rich API, fast, lazily parsed, low memory footprint JSON library for Java

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

9 stars

Watchers

20 watching

Forks

Latest commit

 

History

192 Commits

Folders and files

json-tree

main

A lazily parsed JSON virtual tree library for Java.

Virtual here means it represents the "wanted" or "expected" tree structure. On leaf value access it is checked against the actual tree structure underneath, so navigation is painless and checks only happen when values are resolved (extracted) from the actual tree.

Lazily parsed means only the parts of the underlying tree that are used during navigation get parsed into nodes which remember offsets ("pointers") into the original JSON input. Untouched parts are skipped over until they are used. This makes for a fast, memory-efficient implementation that is convenient to query and can be extended with user types, handling inputs in the MB range without problems.

Quick start

    // parsing JSON text
    JsonArray numbers = JsonMixed.of("[1,2,3]");
    int v1 = numbers.get(1).intValue(); // = 2
    int[] values = numbers.intValues().toArray(); // = [1,2,3]

    // programmatic Java => JSON
    JsonString  s = Json.of( "hello" );   // note: no quotes
    JsonInteger i = Json.of( 42 );

    // programmatic dynamic composition Java => JSON
    JsonObject root = Json.object( obj ->
        obj.addNumber( "x", 1 ).addNumber( "y", 5 ) );
    root.toJson();   // {"x":1,"y":5}

Documentation

Maven

Coordinates:

<dependency>
    <groupId>org.hisp.dhis</groupId>
    <artifactId>json-tree</artifactId>
    <version>1.12.0</version>
</dependency>

License

BSD 3-Clause License

About

A rich API, fast, lazily parsed, low memory footprint JSON library for Java

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

9 stars

Watchers

20 watching

Forks

Used by

Contributors

Languages