Replies: 1 comment 1 reply
-
|
If you would like a good answer to your question, I recommend providing concrete details. The question is somewhat abstract. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a kind of follow-up question to #2223 .
It is doesn't make sense to do
value.get_string().value()repeatedly in a single loop. However considering the following use casesimdjsonobject is created from an string input["$.key1", "$.key1"]) or they have overlapping with each other, e.g.["$.key1.key2", "$.key1.key0", "$.key3", "$key3.key4"]It will be inevitably to go through the simdjson object repeatedly. And due to the underlying buffer held by the parser, every time a json path item is processed, the underlying buffer will be advanced, and it would be chances to overflow without even notice.
So what's the sugested way to do this?
What I can think of, there will be two approaches
field.unescaped_key(char *buffer),value.get_string(char * buffer), allow the caller to provide the buffer to use for the returned string_view, so the interfaces will be independent to the underlying string buffer.B.T.W. the interface
simdjson_inline simdjson_warn_unused error_code field::unescaped_key(string_type& receiver, bool allow_replacement)added in PR #2224 is risky and error-prone.When the caller is running with the code snippet,
It looks like the unescaped_key is stored directly into the std::string, BUT actually the underlying string buffer will be forwarded even an
std::stringis provided.it is identical to the following code.
std::string_view key_view = field.unescaped_key(); std::string key(key_view);Beta Was this translation helpful? Give feedback.
All reactions