From b4dd1c912e792cea3262a4d763e07a91df125892 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Fri, 3 Mar 2023 18:45:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DJSON=E4=B8=BA=E5=8F=B6?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E6=97=B6=EF=BC=8C=E9=81=8D=E5=8E=86=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sane/gb_json.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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;