Giter Club home page Giter Club logo

yasjl's Introduction

yasjl

Yet another simple/streaming/stack-based json library

Features

  • Works on bytebuf, allows streaming partial reads
  • Use json pointers to read specific values in bytebufs
  • Callbacks to get notifications on values
  • Supports "-" for json array any element match
  • Zero copy for parsing, but copies value only on request using a callback

Takes inspiration from Jsonsl, blackberry json-parser

Example

Create Json pointers with callback to fetch value

JsonPointer[] jsonPointers = {
    new JsonPointer("/results/-",  new JsonPointerCB1() {
        public void call(ByteBuf buf) {
            //get value for the json pointer
            System.out.println(buf.toString(Charset.defaultCharset()));
            buf.release();
        })
};

Initialize the parser with the ByteBuf which has the JSON content and json pointers

parser.initialize(buf, jsonPointers);

Parse the current readable bytes and does callback if there was a reference to a json pointer. This will throw EOFException if more content is required to finish parsing

parser.parse(); 

Simple benchmark results

size: 78.2 MB,      level-depth: 0,     time: 26ms
size: 3.2 MB,       level-depth: 3,     time: 345ms
size: 429.2 kB,     level-depth: 4,     time: 9ms
size: 9.7 MB,       level-depth: 5,     time: 69ms
size: 9.7 MB,       level-depth: 5,     time: 58ms
size: 16.8 kB,      level-depth: 2,     time: 0ms
size: 874 B,        level-depth: 4,     time: 0ms
size: 775 B,        level-depth: 5,     time: 0ms
size: 243 B,        level-depth: 4,     time: 0ms
size: 3.5 kB,       level-depth: 4,     time: 0ms
size: 4.2 kB,       level-depth: 4,     time: 0ms
size: 602 B,        level-depth: 4,     time: 0ms
size: 1.1 kB,       level-depth: 6,     time: 0ms
size: 1.4 kB,       level-depth: 5,     time: 0ms
size: 18.4 kB,      level-depth: 5,     time: 0ms
size: 39.5 kB,      level-depth: 4,     time: 1ms
size: 1.2 kB,       level-depth: 6,     time: 1ms

Bench usage

Bench <json-file> <iteration-count>

yasjl's People

Contributors

bsubhashni avatar daschl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

daschl

yasjl's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.