It’s not fully finished yet, but it’s getting there, and i didn’t write documentation beyond the README.md and tests/test.cpp but I’d like some feedback on it.

features

  • It’s a header only library that’s currently < 3000 loc
  • no 3rd-party dependencies
  • support for being imported as a module
  • supports inserting std containers into json nodes
  • highly type safe, which is made possible by using concepts
  • easy-to-use object/array iterations
  • easy-to-use type casting from json value to native c++ types which is enabled by std::variant and concepts
  • exception-free parsing and value casting.
  • modern error handling using “expected” type
  • exception-free node.try_at(“key”) access
  • and more

edit:

documentation link: https://nodeluna.github.io/ljson

  • nodeluna@programming.devOP
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    2 个月前

    thank you! if someone wants a more modern API that’s kinda similar to tomlplusplus and a little nicer to use with modern error handling then my library might come in handy. my API is inspired a lot by tomlplusplus . i was trying to make a build system that uses TOML as a config file and I needed a json library so i decided to make my own as a learning experience which was great.

    I’m not familiar with simdjson, but i know a little about nlohmann and I think the exception free path using ljson::expected is a nicer/safer approach. also there is convenient operator overloads in my library to add objects/array together, but nlohmann also has that i think

    // accessing values in ljson
    ljson::node node = ljson::parser::parse(raw_json);
    std::string val = node.at("key").as_string();
    
    // accessing values in nlohmann
    nlohmann::json::json json;
    raw_json >> json;
    std::string val = json["key"].get<std::string>();