修复JSON为叶节点时,遍历的问题
This commit is contained in:
parent
b4dd1c912e
commit
e92e66f2e5
|
@ -236,23 +236,23 @@ namespace gb
|
||||||
cj = cj->next;
|
cj = cj->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arr_val_.size() == 1 && arr_val_[0]->arr_val_.size() == 0)
|
//if (arr_val_.size() == 1 && arr_val_[0]->arr_val_.size() == 0)
|
||||||
{
|
//{
|
||||||
json* child = arr_val_[0];
|
// json* child = arr_val_[0];
|
||||||
|
//
|
||||||
if (!child->key_.empty()) // array
|
// if (!child->key_.empty()) // array
|
||||||
{
|
// {
|
||||||
arr_val_.clear();
|
// arr_val_.clear();
|
||||||
type_ = child->type_;
|
// type_ = child->type_;
|
||||||
key_ = child->key_;
|
// key_ = child->key_;
|
||||||
simple_val_.dval = child->simple_val_.dval;
|
// simple_val_.dval = child->simple_val_.dval;
|
||||||
strval_ = child->strval_;
|
// strval_ = child->strval_;
|
||||||
for (auto& v : child->arr_val_)
|
// for (auto& v : child->arr_val_)
|
||||||
arr_val_.push_back(v);
|
// arr_val_.push_back(v);
|
||||||
child->arr_val_.clear();
|
// child->arr_val_.clear();
|
||||||
child->release();
|
// child->release();
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
if (arr_val_.size())
|
if (arr_val_.size())
|
||||||
{
|
{
|
||||||
|
@ -521,10 +521,11 @@ namespace gb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
// leaf node, return self
|
// leaf node, return self
|
||||||
add_ref();
|
//add_ref();
|
||||||
|
|
||||||
return this;
|
//return this;
|
||||||
}
|
}
|
||||||
json* json::next_child(void)
|
json* json::next_child(void)
|
||||||
{
|
{
|
||||||
|
@ -1601,13 +1602,13 @@ namespace gb
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cont("");
|
std::string cont("");
|
||||||
if (jsn_->is_leaf_node())
|
//if (jsn_->is_leaf_node())
|
||||||
{
|
//{
|
||||||
jsn_->value(cont);
|
// jsn_->value(cont);
|
||||||
cont.insert(0, "{\"" + jsn_->key() + "\":\"");
|
// cont.insert(0, "{\"" + jsn_->key() + "\":\"");
|
||||||
cont += "\"}";
|
// cont += "\"}";
|
||||||
}
|
//}
|
||||||
else
|
//else
|
||||||
cont = jsn_->to_string();
|
cont = jsn_->to_string();
|
||||||
if (b64)
|
if (b64)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue