diff --git a/sane/gb_json.cpp b/sane/gb_json.cpp index 0964150..32d3cbb 100644 --- a/sane/gb_json.cpp +++ b/sane/gb_json.cpp @@ -510,9 +510,9 @@ namespace gb } json* json::first_child(void) { + cur_child_ = 0; if (type_ == VAL_TYPE_OBJECT || type_ == VAL_TYPE_ARRAY) { - cur_child_ = 0; if (arr_val_.size()) { arr_val_[0]->add_ref(); @@ -521,7 +521,10 @@ namespace gb } } - return nullptr; + // leaf node, return self + add_ref(); + + return this; } json* json::next_child(void) { @@ -1597,7 +1600,15 @@ namespace gb jsn_->set_value("ver", ver); } - std::string cont(jsn_->to_string()); + std::string cont(""); + if (jsn_->is_leaf_node()) + { + jsn_->value(cont); + cont.insert(0, "{\"" + jsn_->key() + "\":\""); + cont += "\"}"; + } + else + cont = jsn_->to_string(); if (b64) { gb::base64 b64;