-
Notifications
You must be signed in to change notification settings - Fork 472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support of the command JSON.DEBUG MEMORY #2323
Changes from 22 commits
0e52a78
0ba0fb5
f4005e4
15ed6fe
c4d9759
cb10eca
d563233
895ea71
5a361a2
4a3cb79
e45dcd1
e0e9faf
eb639b9
e23d0b0
17b3971
5f2b03f
a955aa8
15db3ef
5fb1dac
31ca58d
847858e
e0d69eb
29cda5d
38521ca
e4e4f80
9062108
e5de0c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -217,6 +217,29 @@ struct JsonValue { | |||||||
return results; | ||||||||
} | ||||||||
|
||||||||
StatusOr<std::vector<size_t>> GetBytes(std::string_view path, JsonStorageFormat format, | ||||||||
int max_nesting_depth = std::numeric_limits<int>::max()) const { | ||||||||
std::vector<size_t> results; | ||||||||
Status s; | ||||||||
try { | ||||||||
jsoncons::jsonpath::json_query(value, path, [&](const std::string & /*path*/, const jsoncons::json &origin) { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello, I have two questions I would like to ask. 1. When does the status initialization fail and needs to be returned in advance? 2. Currently, obtaining the byte is still inaccurate, and the actual value should be larger than the encoded string. size(). Does this meet the project's standards? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no initialization failure. We should check it since the lambda function can be executed more than once. |
||||||||
std::string buffer; | ||||||||
JsonValue query_value(origin); | ||||||||
if (format == JsonStorageFormat::JSON) { | ||||||||
s = query_value.Dump(&buffer, max_nesting_depth); | ||||||||
} else if (format == JsonStorageFormat::CBOR) { | ||||||||
s = query_value.DumpCBOR(&buffer, max_nesting_depth); | ||||||||
} | ||||||||
results.emplace_back(buffer.size()); | ||||||||
}); | ||||||||
} catch (const jsoncons::jsonpath::jsonpath_error &e) { | ||||||||
return {Status::NotOK, e.what()}; | ||||||||
} | ||||||||
if (!s) return {Status::NotOK, s.Msg()}; | ||||||||
|
||||||||
return results; | ||||||||
} | ||||||||
|
||||||||
StatusOr<JsonValue> Get(std::string_view path) const { | ||||||||
try { | ||||||||
return jsoncons::jsonpath::json_query(value, path); | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.