]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
json_object_set_boolean for upstream style check
authorStoian Ivanov <sdr@mail.bg>
Tue, 20 Sep 2016 22:31:00 +0000 (01:31 +0300)
committerStoian Ivanov <sdr@mail.bg>
Tue, 20 Sep 2016 22:31:00 +0000 (01:31 +0300)
json_object.c
json_object.h

index f657afe55c279da6dc8c2c570ca4e963bc07f289..4f74a20503b2c09b84ab9ec12e0167013d1db042 100644 (file)
@@ -568,6 +568,13 @@ json_bool json_object_get_boolean(const struct json_object *jso)
        }
 }
 
+json_bool json_object_set_boolean(struct json_object *jso,json_bool new_value){
+       if (!jso || jso->o_type!=json_type_boolean)
+               return FALSE;
+       jso->o.c_boolean=new_value;
+       return TRUE;
+}
+
 
 /* json_object_int */
 
index b6fd917cea21e462eea87a6740d8800f2f028e1f..63c3dc7215dec125989fc731348e4bc0d5b2a5cc 100644 (file)
@@ -620,6 +620,19 @@ extern struct json_object* json_object_new_boolean(json_bool b);
 extern json_bool json_object_get_boolean(const struct json_object *obj);
 
 
+/** Set the json_bool value of a json_object
+ * 
+ * The type of obj is checked to be a json_type_boolean and FALSE is returned 
+ * if it is not without any further actions. If type of obj is json_type_boolean
+ * the obect value is chaned to new_value
+ *
+ * @param obj the json_object instance
+ * @param new_value the value to be set
+ * @returns TRUE if value is set correctly
+ */
+extern json_bool json_object_set_boolean(struct json_object *obj,json_bool new_value);
+
+
 /* int type methods */
 
 /** Create a new empty json_object of type json_type_int