diff --git a/examples/quickstart/quickstart.cpp b/examples/quickstart/quickstart.cpp index 70f327489..44705400d 100644 --- a/examples/quickstart/quickstart.cpp +++ b/examples/quickstart/quickstart.cpp @@ -49,10 +49,10 @@ int main(void) { // auto result = parsed_json.at_path_new("$.address.*"); // selects all address properties - $["address"].* - // auto result = parsed_json.at_path_new("$["address"].*"); + auto result = parsed_json.at_path_new("$['address'].*"); // selects nested properties - $.*.streetAddress - auto result = parsed_json.at_path_new("$.*.streetAddress"); + // auto result = parsed_json.at_path_new("$.*.streetAddress"); std::vector values = result.value(); diff --git a/include/simdjson/dom/object-inl.h b/include/simdjson/dom/object-inl.h index 0588a1232..aaca01c5b 100644 --- a/include/simdjson/dom/object-inl.h +++ b/include/simdjson/dom/object-inl.h @@ -237,7 +237,7 @@ object::at_path_new(std::string_view json_path) const noexcept { // recursive e.g example_key.* or example_key[*] size_t second_dot = json_path.find('.'); - if (second_dot != std::string_view::npos && json_path[0] != '"') { + if (second_dot != std::string_view::npos && (json_path[0] != '"' && json_path[0] != '\'')) { auto key = json_path.substr(0, second_dot); // example_key or * simdjson_result> child = {}; @@ -265,8 +265,8 @@ object::at_path_new(std::string_view json_path) const noexcept { // recursive e.g "example_key"].* or "example_key"][*] size_t close_bracket = json_path.find(']'); - if (close_bracket != std::string_view::npos && json_path[0] == '"') { - auto key = json_path.substr(1, close_bracket - 1); // example_key or * + if (close_bracket != std::string_view::npos && (json_path[0] == '"' || json_path[0] == '\'')) { + auto key = json_path.substr(1, close_bracket - 2); // example_key or * simdjson_result> child = {}; if (key == "*") {