Open
Description
For C++20 users, we support std::ranges
somewhat under the DOM API but it is undocumented.
#include "simdjson.h"
#include <iostream>
#include <ranges>
using namespace simdjson;
int main(void) {
auto cars_json = R"( [
{ "make": "Toyota", "model": "Camry", "year": 2018, "tire_pressure": [ 40.1, 39.9, 37.7, 40.4 ] },
{ "make": "Kia", "model": "Soul", "year": 2012, "tire_pressure": [ 30.1, 31.0, 28.6, 28.7 ] },
{ "make": "Toyota", "model": "Tercel", "year": 1999, "tire_pressure": [ 29.8, 30.0, 30.2, 30.5 ] }
] )"_padded;
dom::parser parser;
auto justmodel = [](auto car) { return car["model"]; };
for (auto car : parser.parse(cars_json).get_array() | std::views::transform(justmodel)) {
std::cout << car << std::endl;
}
}
Also it would be nice to extend std::ranges
to ondemand.
Metadata
Metadata
Assignees
Labels
No labels