From 02b5137bf64407153ba11efbb670413930913690 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 29 Aug 2019 18:54:35 +0800 Subject: [PATCH] add ToKvList --- a8/xobject.cc | 9 +++++++++ a8/xobject.h | 1 + 2 files changed, 10 insertions(+) diff --git a/a8/xobject.cc b/a8/xobject.cc index 671a83c..0af198d 100644 --- a/a8/xobject.cc +++ b/a8/xobject.cc @@ -420,6 +420,15 @@ namespace a8 } } + void XObject::ToKVList(std::map& kv_list) + { + if (type_ == a8::XOT_OBJECT) { + for (auto& pair : *value_.object_value) { + kv_list[pair.first] = pair.second->AsXValue().GetString(); + } + } + } + void XObject::JsonValueToXObject(Json::Value& json_val, a8::XObject& xobject) { Json::ValueType val_type = json_val.type(); diff --git a/a8/xobject.h b/a8/xobject.h index 1214d11..4e2d8ce 100644 --- a/a8/xobject.h +++ b/a8/xobject.h @@ -52,6 +52,7 @@ namespace a8 void ToJsonStr(std::string& data); std::string ToJsonStr(); void ToUrlEncodeStr(std::string& data); + void ToKVList(std::map& kv_list); private: void JsonValueToXObject(Json::Value& json_val, a8::XObject& xobject);