]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
formattable: more fixes
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 9 Jan 2018 15:40:11 +0000 (07:40 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 12 Apr 2018 22:38:38 +0000 (15:38 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/common/ceph_json.cc

index 656189dc0f7ad5be622ab63c0f6d49a989eb3793..89252b272b6da098361327092aa761abbc413fa9 100644 (file)
@@ -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<field_entity> 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;
 }