Version 4.0.0
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
- Corrected “AP” to “API” in the builder API link.
- Corrected “deseriallization” to “deserialization” (fixed double “l”).
- Ensured consistent formatting and clarity in code examples and text.
What's Changed (details)
- Fixing MSYS2 issue by @lemire in #2380
- Add document and tests of std::ranges support of DOM API by @Cuda-Chen in #2381
- Replace
-fPICwithPOSITION_INDEPENDENT_CODE. by @xkszltl in #2383 - guarding the POSITION_INDEPENDENT_CODE by @lemire in #2386
- clarifying NDEBUG usage by @lemire in #2388
- improving DOM ranges test and silencing a warning by @lemire in #2385
- C++26 static reflection by @lemire in #2282
- Improve fallback implementation by @evbse in #2393
- minor update to the release candidate by @lemire in #2394
- Add version to amalgamated files by @evbse in #2400
- Bringing a bit more use-cases for reflection based serializations (optional). Also adding string-based enum handling as requested on X. by @FranciscoThiesen in #2395
- Fix linker errors for downstream users caused by non-inline symbols in header by @abbator in #2403
- remove cmake_policy by @iboB in #2404
- release candidate 4.0.0 by @lemire in #2392
- Sped up serialization by 10..70%-ish by @toughengineer in #2408
- Sped up serialization fix by @lemire in #2409
- Minor cleanup by @toughengineer in #2411
- Fix convert ci failures by @FranciscoThiesen in #2406
- introducing a thread-local parser by @lemire in #2412
- improve how we pad strings. by @lemire in #2415
- Adding DOM support for json path with wildcard by @dabigjoe6 in #2346
- Use std::string_view in parser.load function by @joshuagawley in #2417
- improving the documentation of raw json access by @lemire in #2416
- This is a small reorg of the new convert code so that we only expose 'simdjson::from' as experimental by @lemire in #2418
- doing more to discourage value_unsafe(); by @lemire in #2421
- Renames a few macros and extends slightly our basic builder by @lemire in #2422
- fix issue 2424 by @lemire in #2425
- Add "node:" prefix on fs import by @felipee-monteiro in #2426
- adding a 'car builder' benchmark by @lemire in #2428
- removing expand workaround by @lemire in #2431
- Adds -> and * operators to our error types and it improves slightly the documentation. by @lemire in #2433
- can we run the address sanitizer under VS in CI ? by @lemire in #2435
New Contributors
- @xkszltl made their first contribution in #2383
- @evbse made their first contribution in #2393
- @abbator made their first contribution in #2403
- @iboB made their first contribution in #2404
- @dabigjoe6 made their first contribution in #2346
- @joshuagawley made their first contribution in #2417
- @felipee-monteiro made their first contribution in #2426
Full Changelog: v3.13.0...v4.0.0