Giter VIP home page Giter VIP logo

json5cpp's Introduction

json5cpp

Build Status Test Status Coverage

C++ library for parsing and stringifying JSON5 data

This is a port of the JavaScript reference implementation to C++.

Project Status

The core functionality is completely implemented and the test coverage is as close to 100% as possible without causing compiler warnings. See the tests for usage examples.

Design Principles

  • Sticking to the reference implementation as much as sensible.
  • No dependencies apart from the STL.
  • Minimalism.

Limitations

  • Due to a lack of experience in writing safety-critical software, this library should probably not be used where security is important. Please open issues for any vulnerabilities you spot.
  • So far, the number data type only supports doubles, no ints. You can of course store ints in doubles but only from -2^53 to 2^53 without losing precision.
  • Only UTF-8 is supported (which includes ASCII), no UTF-16, no UTF-32, no ISO 8859 or Windows character encodings.
  • Unquoted keys can be ECMAScript Identifier Names with Unicode 10.0 characters (because that is the version used in the reference implementation).
  • Parsing objects with unquoted non-ASCII keys may take significantly longer as a linear search is performed for verifying the Unicode category of each character. Consider quoting the keys or sticking to ASCII.
  • Stringifying objects with non-ASCII keys may also take longer with no way around it yet. Consider using ASCII keys.
  • In JavaScript, you can pass a reviver function to transform JSON into your own datastructure during parse. This does not really work in C++ so it was left out. Transformation into your datastructure has to be done afterwards.
  • There is also no replacer function for filtering and transforming your JSON data during stringification. That must be done beforehand.

ToDos

  • Provide fromJson and toJson facilities for basic STL types.
  • Put a how-to-use demo into the readme.
  • Implement integer data types (how to decide if a parsed integer is int64_t or uint64_t?).
  • Implement a more efficient way of verifying identifier name Unicode categories (or provide an option to skip that entirely).
  • Make the peek() function caching for speed up.
  • Implement a replacer function for stringification if somebody needs that.
  • Implement UTF-16 and UTF-32 encoding and decoding if somebody needs that.

License

MIT

Pleasantries

I hope you enjoy almost the elegance of JSON combined with the utility of comments, NaN and Infinity (among other actually really useful tweaks), all delivered with the performance of C++! Feel free to report issues and request pull requests!

json5cpp's People

Contributors

mqnc avatar

Watchers

 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.