Skip to content
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

Json uses a packed tree representation #1112

Merged
merged 4 commits into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions libs/yocto/yocto_commonio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,18 +660,18 @@ bool load_json(const string& filename, json_tree& js, string& error) {
// sax handler
struct sax_handler {
// stack
json_view root;
json_view root;
std::vector<json_view> stack = {};
std::string current_key;
explicit sax_handler(json_view root_) : root{root_}, stack{root_} {
}
std::string current_key;
explicit sax_handler(json_view root_) : root{root_}, stack{root_} {}

// get current value
json_view next_value() {
if (stack.size() == 1) return root;
auto& jst = _get_type(stack.back());
if (jst == json_type::array) return append_element(stack.back());
if (jst == json_type::object) return insert_element(stack.back(), current_key);
if (jst == json_type::object)
return insert_element(stack.back(), current_key);
throw yocto::json_error{"bad json type"};
}

Expand Down
Loading