Add automatic rewind for at_pointer (#1624)
This commit is contained in:
parent
6cd04aa858
commit
ce38fe7bea
|
@ -54,7 +54,7 @@ public:
|
|||
* auto doc = parser.iterate(json);
|
||||
* doc.at_pointer("/0/foo/a/1") == 20
|
||||
*
|
||||
* Note that at_pointer() does not automatically rewind between each call (call rewind() to reset).
|
||||
* Note that at_pointer() automatically calls rewind between each call.
|
||||
* Also note that at_pointer() relies on find_field() which implies that we do not unescape keys when matching.
|
||||
* @return The value associated with the given JSON pointer, or:
|
||||
* - NO_SUCH_FIELD if a field does not exist in an object
|
||||
|
|
|
@ -135,6 +135,7 @@ simdjson_really_inline simdjson_result<std::string_view> document::raw_json_toke
|
|||
}
|
||||
|
||||
simdjson_really_inline simdjson_result<value> document::at_pointer(std::string_view json_pointer) noexcept {
|
||||
rewind(); // Rewind the document each time at_pointer is called
|
||||
if (json_pointer.empty()) {
|
||||
return this->resume_value();
|
||||
}
|
||||
|
|
|
@ -335,7 +335,7 @@ public:
|
|||
* auto doc = parser.iterate(json);
|
||||
* doc.at_pointer("//a/1") == 20
|
||||
*
|
||||
* Note that at_pointer() does not automatically rewind between each call (call rewind() to reset).
|
||||
* Note that at_pointer() automatically calls rewind between each call.
|
||||
* Also note that at_pointer() relies on find_field() which implies that we do not unescape keys when matching
|
||||
*
|
||||
* @return The value associated with the given JSON pointer, or:
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
* auto doc = parser.iterate(json);
|
||||
* doc.at_pointer("//a/1") == 20
|
||||
*
|
||||
* Note that at_pointer() does not automatically rewind between each call (call rewind() to reset).
|
||||
* Note that at_pointer() automatically calls rewind between each call.
|
||||
* Also note that at_pointer() relies on find_field() which implies that we do not unescape keys when matching.
|
||||
*
|
||||
* @return The value associated with the given JSON pointer, or:
|
||||
|
|
|
@ -330,7 +330,7 @@ public:
|
|||
* auto doc = parser.iterate(json);
|
||||
* doc.at_pointer("//a/1") == 20
|
||||
*
|
||||
* Note that at_pointer() does not automatically rewind between each call (call rewind() to reset).
|
||||
* Note that at_pointer() automatically calls rewind between each call.
|
||||
* Also note that at_pointer() relies on find_field() which implies that we do not unescape keys when matching
|
||||
*
|
||||
* @return The value associated with the given JSON pointer, or:
|
||||
|
|
|
@ -117,7 +117,6 @@ namespace json_pointer_tests {
|
|||
std::string json_pointer = "/" + std::to_string(i) + "/tire_pressure/1";
|
||||
ASSERT_SUCCESS(cars.at_pointer(json_pointer).get(x));
|
||||
measured.push_back(x);
|
||||
cars.rewind();
|
||||
}
|
||||
|
||||
std::vector<double> expected = {39.9, 31, 30};
|
||||
|
|
Loading…
Reference in New Issue