GithubHelp home page GithubHelp logo

rjson's Introduction

rjson : a minimal json parser for rust

  • Contain a single standalone lib.rs that do all the jobs.
  • Impl the traits with your own structs before parse.
  • A simple Impl can be, enum for Value, the same enum for Null, Vec for Array and BTreeMap for Object.
  • It requires only core and alloc, nothing else, including std.
  • In no_std environment, it need a global allocator to work.

Reminder

  • We allow , after the last item/member of Array/Object.
  • We treat unescaped line breaks as normal char, and ignore escaped line breaks.
  • We do not support surrogate unicode char.
  • We use f64 for all numbers. Also supported u64, i64. JSON standard not supported u128 and i128. Any other number you can simply cast. To enable integers use feature integer (see tests/mod.rs). Remind: f64 means i52.
  • We take &[char], not &[u8], and not &str.
  • No stringify or encode, because they should not be a part of the traits.
  • Instead of returning None, we simply ignore chars after the data.
  • The position where data ends is returned through index. You can compare it with len() - 1.
  • This value is also useful when Option::None returned, by indicating where the syntax error occurs.
  • parse may return all possible values, not only Array and Object.

For more examples and additional parsers you can see tests/mod.rs.

rjson's People

Contributors

mrlsd avatar yw662 avatar

Watchers

 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.