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