Skip to content

Version 4.0.0

Choose a tag to compare

@lemire lemire released this 11 Sep 23:50
· 148 commits to master since this release
124a33c

Version 4.0.0 is a major new release

Version 4.0.0 is a major release introducing many new features. It is a wide-ranging community effort.

Builder API

We introduce a builder API that allows users to convert their data structures to JSON strings. In simple cases, you can use code as straightforward as:

std::vector<std::vector<double>> c = {{1.0, 2.0}, {3.0, 4.0}};
std::string json = simdjson::to_json(c);

Please refer to our documentation for more details.

Experimental support for C++26 static reflection

Mainstreaming compilers do not yet support C++26. You can activate support for C++26 static reflection with the SIMDJSON_STATIC_REFLECTION=ON option in CMake (or setting the macro SIMDJSON_STATIC_REFLECTION to 1). We make it easy to build and run simdjson software using docker containers, see our documentation.

https://github.com/simdjson/simdjson/blob/master/p2996/README.md

Static reflection enables parsing or serializing custom classes. For example:

struct Car {
    std::string make;
    std::string model;
    int64_t year;
    std::vector<double> tire_pressure;
};
void f() {
    Car c = {"Toyota", "Corolla", 2017, {30.0, 30.2, 30.513, 30.79}};
    std::string json = simdjson::to_json(c);
}

Or:

struct Car {
    std::string make;
    std::string model;
    int year;
    std::vector<float> tire_pressure;
};
std::string json = R"( { \"make\": \"Toyota\", \"model\": \"Camry\", \"year\": 2018,
       \"tire_pressure\": [ 40.1, 39.9 ] } )";
simdjson::ondemand::parser parser;
simdjson::ondemand::document doc = parser.iterate(simdjson::pad(json));
Car c = doc.get<Car>();

Shortcut for parsing

With simdjson::from, you can quickly deserialize a JSON string:

Car car = simdjson::from(json);
for (auto val : simdjson::from(json).array()) {
    Car c = val.get<Car>();
}

We have also added a thread-local parser, accessible via simdjson::ondemand::parser::get_parser().

Please review to the On-Demand documentation.

Corrections made

  1. Corrected “AP” to “API” in the builder API link.
  2. Corrected “deseriallization” to “deserialization” (fixed double “l”).
  3. Ensured consistent formatting and clarity in code examples and text.

What's Changed (details)

New Contributors

Full Changelog: v3.13.0...v4.0.0