From: Yehuda Sadeh Date: Tue, 9 Jan 2018 09:30:37 +0000 (-0800) Subject: formattable: fixes X-Git-Tag: v13.1.0~270^2~34 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0c71d8bb647ed63b1a969b768ae658a4a93abb29;p=ceph-ci.git formattable: fixes Signed-off-by: Yehuda Sadeh --- diff --git a/src/common/ceph_json.cc b/src/common/ceph_json.cc index f43fce8bfa8..656189dc0f7 100644 --- a/src/common/ceph_json.cc +++ b/src/common/ceph_json.cc @@ -694,7 +694,16 @@ int JSONFormattable::set(const string& name, const string& val) JSONParser jp; - bool is_json = jp.parse(val.c_str(), val.size()); + 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; + } for (auto i : tok) { vector v; @@ -737,12 +746,7 @@ int JSONFormattable::set(const string& name, const string& val) } } - if (is_json) { - f->decode_json(&jp); - } else { - f->type = FMT_STRING; - f->str = val; - } + f->decode_json(&jp); return 0; } @@ -763,7 +767,8 @@ int JSONFormattable::erase(const string& name) return ret; } for (auto vi : v) { - if (f->type == FMT_NONE) { + if (f->type == FMT_NONE || + f->type == FMT_STRING) { if (vi.is_obj) { f->type = FMT_OBJ; } else {