Add document and tests of std::ranges support of DOM API#2381
Merged
lemire merged 3 commits intosimdjson:masterfrom Jun 24, 2025
Merged
Add document and tests of std::ranges support of DOM API#2381lemire merged 3 commits intosimdjson:masterfrom
lemire merged 3 commits intosimdjson:masterfrom
Conversation
0c79baa to
d388ff9
Compare
d388ff9 to
25eac1a
Compare
Member
|
@Cuda-Chen Great work. What about code that looks like this... 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;
simdjson::dom::parser parser;
auto cars = parser.parse(cars_json).get_array() |
std::views::transform([](auto car) -> std::string_view {
return car["model"].get_string();
});
return std::ranges::equal(
cars, std::vector<std::string_view>{"Camry", "Soul", "Tercel"})
? EXIT_SUCCESS
: EXIT_FAILURE;Note that you do not need the |
Contributor
Author
|
Hi @lemire ,
I think this solution appears more acceptable, and I will adopt this one. |
25eac1a to
cecb648
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add document and tests of
std::rangessupport of DOM API.Mention #1826.