Skip to content

Commit

Permalink
Json uses a packed tree representation (#1112)
Browse files Browse the repository at this point in the history
  • Loading branch information
xelatihy authored Dec 22, 2020
1 parent 2aa0d6a commit 9d1f897
Show file tree
Hide file tree
Showing 2 changed files with 295 additions and 270 deletions.
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

0 comments on commit 9d1f897

Please sign in to comment.