修复JSON为叶节点时,遍历的问题
This commit is contained in:
parent
6c3f32c5de
commit
b4dd1c912e
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue