GithubHelp home page GithubHelp logo

jsmn-rs's Introduction

jmsn-rs

The jsmn-rs crate provide a rustic interface to an absolute gem of a C library called jsmn. The jsmn library is a JSON parser which, in the words of its author, is fast, portable, and simple. It does no memory allocation, and does not build of a tree of nodes with pointers- instead it fills out an array of structures, and children are indicated by indices into the array.

The thing I love most about this library is its simplicity- it contains exactly 2 enums, 2 structs, and 2 functions, with a total of 1 header file and 1 .c file.

The rustic wrapping includes using bindgen to generate raw bindings, available from the raw module, and then wrapping those up in standard rust naming conventions. This means using slices instead of pointers and lengths, and returning a Result from jsmn_parse instead of a number that can be an error code or count.

Features

This library provides two features, "parent-links" and "strict" which can be set when adding jsmn-rs as a dependancy in Cargo.toml. These add the pre-processor directives JSMN_PARENT_LINKS and JSMN_STRICT, respectively, when compiling jsmn and generating the jsmn bindings.

I've used this library without the strict setting as a quick way to read configuration files, and I've seen some benchmarks which show that the parent-links can increase performance enormously.

TODO

Ideally it would be tested on 64 and 32 bit machines, as I'm not sure whether the use of "int" in the C source will cause problems here. I tried to use isize and usize to make this okay, but for some casts it might still be a problem.

There are also very few tests and very little example code on how to use the library.

jsmn-rs's People

Contributors

nsmryan avatar

Stargazers

Tim van Scherpenzeel avatar Christoph Grabo avatar

Watchers

James Cloos avatar  avatar  avatar

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.