Skip to content

syoyo/minijson

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

minijson

minimal but secure JSON parser

Features

  • Single header-only.
  • minimal STL dependency.
  • No C++ RTTI and C++ exceptions
    • Easy to embed to your app.
  • Fuzz tested
    • Parser should not crash for invalid/malcious input.
  • Support UTF8 Unicode escape sequence(\uXXXX)
  • Robust parsing of floating point string.

Limitation

  • Duplicated key is not allowed

Usage

const char* foo = R"(
{"empty":{"":[]}, "foo":
3.2, "bar": "baz", "baz": true,"hoge":{"a":"あい\nうおえ"}, "moge": null, "zz": 255
, "rrr":[[2,"3"], "4"], "fuba": 1e9}
)";
minijson::error e = minijson::parse(p, v);

The pointer p will be shift to the end of token. So it is the caller's responsibility to check whether the extra tokens are treated as errors.

License

MIT

Third party licenses

Author

Yasuhiro Matsumoto

Modification by Syoyo Fujita.

TODO

  • Pretty print
  • Unicode escape sequence and other escape characters.
    • Thanks to nlohmann json's scan_string()
  • Harden parse() API
    • Only allow string with length parameter
  • Write robust JSON writer
    • Escape unicode character

About

simple C++ json library. (clone of kazuho/picojson)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 99.0%
  • Makefile 1.0%