From d9fb18d0a6fae8c20b6ac2de6bc26999ed74c6f1 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 9 Jan 2018 07:40:11 -0800 Subject: [PATCH] formattable: more fixes Signed-off-by: Yehuda Sadeh --- src/common/ceph_json.cc | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/common/ceph_json.cc b/src/common/ceph_json.cc index 656189dc0f7..89252b272b6 100644 --- a/src/common/ceph_json.cc +++ b/src/common/ceph_json.cc @@ -694,16 +694,7 @@ int JSONFormattable::set(const string& name, const string& val) JSONParser jp; - if (!jp.parse(val.c_str(), val.size())) { - /* can't parse, input is raw string */ - if (!name.empty()) { - f->type = FMT_OBJ; - f = &f->obj[name]; - } - f->type = FMT_STRING; - f->str = val; - return 0; - } + bool is_valid_json = jp.parse(val.c_str(), val.size()); for (auto i : tok) { vector v; @@ -746,7 +737,12 @@ int JSONFormattable::set(const string& name, const string& val) } } - f->decode_json(&jp); + if (is_valid_json) { + f->decode_json(&jp); + } else { + f->type = FMT_STRING; + f->str = val; + } return 0; } -- 2.39.5