diff --git a/examples/quickstart/quickstart.cpp b/examples/quickstart/quickstart.cpp index 58eedeeaf..6df0b8426 100644 --- a/examples/quickstart/quickstart.cpp +++ b/examples/quickstart/quickstart.cpp @@ -39,26 +39,28 @@ int main(void) { // std::cout << tweets["search_metadata"]["count"] << " results." << // std::endl; + + simdjson::dom::element parsed_json = parser.parse(json_string); // std::cout << parsed_json["firstName"] << std::endl; // selects all the top level elements - // auto result = parsed_json.at_path_new("$.*"); + auto result = parsed_json.at_path_with_wildcard("$.*"); // selects all the top level elements - // auto result = parsed_json.at_path_new("$[*]"); + // auto result = parsed_json.at_path_with_wildcard("$[*]"); // selects all address properties - $.address.* - // auto result = parsed_json.at_path_new("$.address.*"); + // auto result = parsed_json.at_path_with_wildcard("$.address.*"); // selects all address properties - $["address"].* - // auto result = parsed_json.at_path_new("$['address'].*"); + // auto result = parsed_json.at_path_with_wildcard("$['address'].*"); // selects all phoneNumbers properties - $.phoneNumbers.* - // auto result = parsed_json.at_path_new("$.phoneNumbers.*"); + // auto result = parsed_json.at_path_with_wildcard("$.phoneNumbers.*"); // selects nested properties - $.*.streetAddress - auto result = parsed_json.at_path_new("$.*.streetAddress"); + // auto result = parsed_json.at_path_with_wildcard("$.*.streetAddress"); std::vector values = result.value(); diff --git a/include/simdjson/dom/array-inl.h b/include/simdjson/dom/array-inl.h index 3765e8a35..203478083 100644 --- a/include/simdjson/dom/array-inl.h +++ b/include/simdjson/dom/array-inl.h @@ -70,12 +70,12 @@ inline simdjson_result simdjson_result::at_path( } inline simdjson_result> -simdjson_result::at_path_new( +simdjson_result::at_path_with_wildcard( std::string_view json_path) const noexcept { if (error()) { return error(); } - return first.at_path_new(json_path); + return first.at_path_with_wildcard(json_path); } inline simdjson_result @@ -169,7 +169,7 @@ array::at_pointer(std::string_view json_pointer) const noexcept { } inline simdjson_result> -array::at_path_new(std::string_view json_path) const noexcept { +array::at_path_with_wildcard(std::string_view json_path) const noexcept { if (json_path.length() == 3 && json_path[0] == '$' && json_path[1] == '.' && json_path[2] == '*') { return get_values(); diff --git a/include/simdjson/dom/array.h b/include/simdjson/dom/array.h index d748b7034..8b71bbf6d 100644 --- a/include/simdjson/dom/array.h +++ b/include/simdjson/dom/array.h @@ -109,7 +109,7 @@ public: * - INVALID_JSON_POINTER if the JSON pointer is invalid and cannot be parsed */ inline simdjson_result at_pointer(std::string_view json_pointer) const noexcept; - inline simdjson_result> at_path_new(std::string_view json_path) const noexcept; + inline simdjson_result> at_path_with_wildcard(std::string_view json_path) const noexcept; /** * Get the value associated with the given JSONPath expression. We only support * JSONPath queries that trivially convertible to JSON Pointer queries: key @@ -171,7 +171,7 @@ public: simdjson_inline simdjson_result(error_code error) noexcept; ///< @private inline simdjson_result at_pointer(std::string_view json_pointer) const noexcept; - inline simdjson_result> at_path_new(std::string_view json_path) const noexcept; + inline simdjson_result> at_path_with_wildcard(std::string_view json_path) const noexcept; inline simdjson_result at_path(std::string_view json_path) const noexcept; inline simdjson_result at(size_t index) const noexcept; inline simdjson_result> get_values() const noexcept; diff --git a/include/simdjson/dom/element-inl.h b/include/simdjson/dom/element-inl.h index 25731f2e5..352ca354f 100644 --- a/include/simdjson/dom/element-inl.h +++ b/include/simdjson/dom/element-inl.h @@ -129,9 +129,9 @@ simdjson_inline simdjson_result simdjson_result::at_ return at_pointer(json_pointer); } -simdjson_inline simdjson_result> simdjson_result::at_path_new(const std::string_view json_path) const noexcept { +simdjson_inline simdjson_result> simdjson_result::at_path_with_wildcard(const std::string_view json_path) const noexcept { if (error()) { return error(); } - return first.at_path_new(json_path); + return first.at_path_with_wildcard(json_path); } #ifndef SIMDJSON_DISABLE_DEPRECATED_API @@ -425,14 +425,14 @@ inline simdjson_result element::at_pointer(std::string_view json_pointe } } -inline simdjson_result> element::at_path_new(std::string_view json_path) const noexcept { +inline simdjson_result> element::at_path_with_wildcard(std::string_view json_path) const noexcept { SIMDJSON_DEVELOPMENT_ASSERT(tape.usable()); // https://github.com/simdjson/simdjson/issues/1914 switch (tape.tape_ref_type()) { case internal::tape_type::START_OBJECT: - return object(tape).at_path_new(json_path); + return object(tape).at_path_with_wildcard(json_path); case internal::tape_type::START_ARRAY: - return array(tape).at_path_new(json_path); + return array(tape).at_path_with_wildcard(json_path); default: { return std::vector{}; // if (!json_path.empty()) { // a non-empty string can be invalid, or accessing a primitive (issue 2154) diff --git a/include/simdjson/dom/element.h b/include/simdjson/dom/element.h index 0fd10bdb8..3f1b42c8d 100644 --- a/include/simdjson/dom/element.h +++ b/include/simdjson/dom/element.h @@ -401,7 +401,7 @@ public: */ inline simdjson_result at_pointer(const std::string_view json_pointer) const noexcept; - inline simdjson_result> at_path_new(const std::string_view json_path) const noexcept; + inline simdjson_result> at_path_with_wildcard(const std::string_view json_path) const noexcept; /** * Get the value associated with the given JSONPath expression. We only support @@ -548,7 +548,7 @@ public: simdjson_inline simdjson_result operator[](const char *key) const noexcept; simdjson_result operator[](int) const noexcept = delete; simdjson_inline simdjson_result at_pointer(const std::string_view json_pointer) const noexcept; - simdjson_inline simdjson_result> at_path_new(const std::string_view json_path) const noexcept; + simdjson_inline simdjson_result> at_path_with_wildcard(const std::string_view json_path) const noexcept; simdjson_inline simdjson_result at_path(const std::string_view json_path) const noexcept; [[deprecated("For standard compliance, use at_pointer instead, and prefix your pointers with a slash '/', see RFC6901 ")]] simdjson_inline simdjson_result at(const std::string_view json_pointer) const noexcept; diff --git a/include/simdjson/dom/object-inl.h b/include/simdjson/dom/object-inl.h index aaca01c5b..9a6800566 100644 --- a/include/simdjson/dom/object-inl.h +++ b/include/simdjson/dom/object-inl.h @@ -48,12 +48,12 @@ inline simdjson_result simdjson_result::at_pointer( return first.at_pointer(json_pointer); } inline simdjson_result> -simdjson_result::at_path_new( +simdjson_result::at_path_with_wildcard( std::string_view json_path) const noexcept { if (error()) { return error(); } - return first.at_path_new(json_path); + return first.at_path_with_wildcard(json_path); } inline simdjson_result simdjson_result::at_path( std::string_view json_path) const noexcept { @@ -193,7 +193,7 @@ object::at_pointer(std::string_view json_pointer) const noexcept { return child; } inline simdjson_result> -object::at_path_new(std::string_view json_path) const noexcept { +object::at_path_with_wildcard(std::string_view json_path) const noexcept { SIMDJSON_DEVELOPMENT_ASSERT( tape.usable()); // https://github.com/simdjson/simdjson/issues/1914 if (json_path @@ -255,7 +255,7 @@ object::at_path_new(std::string_view json_path) const noexcept { for (; iterator != child_value.end(); ++iterator) { auto child_result = - iterator->at_path_new("$" + std::string(json_path)).value(); + iterator->at_path_with_wildcard("$" + std::string(json_path)).value(); result.insert(result.end(), child_result.begin(), child_result.end()); } @@ -282,7 +282,7 @@ object::at_path_new(std::string_view json_path) const noexcept { for (; iterator != child_value.end(); ++iterator) { auto child_result = - iterator->at_path_new("$" + std::string(json_path)).value(); + iterator->at_path_with_wildcard("$" + std::string(json_path)).value(); result.insert(result.end(), child_result.begin(), child_result.end()); } diff --git a/include/simdjson/dom/object.h b/include/simdjson/dom/object.h index 3db35ce5e..e8af93655 100644 --- a/include/simdjson/dom/object.h +++ b/include/simdjson/dom/object.h @@ -174,7 +174,7 @@ public: */ inline simdjson_result at_pointer(std::string_view json_pointer) const noexcept; - inline simdjson_result> at_path_new(std::string_view json_path) const noexcept; + inline simdjson_result> at_path_with_wildcard(std::string_view json_path) const noexcept; /** * Get the value associated with the given JSONPath expression. We only support @@ -267,7 +267,7 @@ public: inline simdjson_result operator[](const char *key) const noexcept; simdjson_result operator[](int) const noexcept = delete; inline simdjson_result at_pointer(std::string_view json_pointer) const noexcept; - inline simdjson_result> at_path_new(std::string_view json_path_new) const noexcept; + inline simdjson_result> at_path_with_wildcard(std::string_view json_path_new) const noexcept; inline simdjson_result at_path(std::string_view json_path) const noexcept; inline simdjson_result at_key(std::string_view key) const noexcept; inline simdjson_result> get_values() const noexcept;