mirror of
https://github.com/json-c/json-c.git
synced 2026-04-02 03:49:06 +08:00
some basic set
This commit is contained in:
@@ -568,11 +568,11 @@ 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){
|
int json_object_set_boolean(struct json_object *jso,json_bool new_value){
|
||||||
if (!jso || jso->o_type!=json_type_boolean)
|
if (!jso || jso->o_type!=json_type_boolean)
|
||||||
return FALSE;
|
return 0;
|
||||||
jso->o.c_boolean=new_value;
|
jso->o.c_boolean=new_value;
|
||||||
return TRUE;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -634,6 +634,14 @@ int32_t json_object_get_int(const struct json_object *jso)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int json_object_set_int(struct json_object *jso,int new_value){
|
||||||
|
if (!jso || jso->o_type!=json_type_int)
|
||||||
|
return 0;
|
||||||
|
jso->o.c_int64=new_value;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct json_object* json_object_new_int64(int64_t i)
|
struct json_object* json_object_new_int64(int64_t i)
|
||||||
{
|
{
|
||||||
struct json_object *jso = json_object_new(json_type_int);
|
struct json_object *jso = json_object_new(json_type_int);
|
||||||
@@ -666,6 +674,12 @@ int64_t json_object_get_int64(const struct json_object *jso)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int json_object_set_int64(struct json_object *jso,int64_t new_value){
|
||||||
|
if (!jso || jso->o_type!=json_type_int)
|
||||||
|
return 0;
|
||||||
|
jso->o.c_int64=new_value;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* json_object_double */
|
/* json_object_double */
|
||||||
|
|
||||||
@@ -820,6 +834,12 @@ double json_object_get_double(const struct json_object *jso)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int json_object_set_double(struct json_object *jso,double new_value){
|
||||||
|
if (!jso || jso->o_type!=json_type_double)
|
||||||
|
return 0;
|
||||||
|
jso->o.c_double=new_value;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* json_object_string */
|
/* json_object_string */
|
||||||
|
|
||||||
|
|||||||
@@ -622,15 +622,15 @@ extern json_bool json_object_get_boolean(const struct json_object *obj);
|
|||||||
|
|
||||||
/** Set the json_bool value of a json_object
|
/** 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
|
* The type of obj is checked to be a json_type_boolean and 0 is returned
|
||||||
* if it is not without any further actions. If type of obj is json_type_boolean
|
* if it is not without any further actions. If type of obj is json_type_boolean
|
||||||
* the obect value is chaned to new_value
|
* the obect value is chaned to new_value
|
||||||
*
|
*
|
||||||
* @param obj the json_object instance
|
* @param obj the json_object instance
|
||||||
* @param new_value the value to be set
|
* @param new_value the value to be set
|
||||||
* @returns TRUE if value is set correctly
|
* @returns 1 if value is set correctly, 0 otherwise
|
||||||
*/
|
*/
|
||||||
extern json_bool json_object_set_boolean(struct json_object *obj,json_bool new_value);
|
extern int json_object_set_boolean(struct json_object *obj,json_bool new_value);
|
||||||
|
|
||||||
|
|
||||||
/* int type methods */
|
/* int type methods */
|
||||||
@@ -667,6 +667,19 @@ extern struct json_object* json_object_new_int64(int64_t i);
|
|||||||
*/
|
*/
|
||||||
extern int32_t json_object_get_int(const struct json_object *obj);
|
extern int32_t json_object_get_int(const struct json_object *obj);
|
||||||
|
|
||||||
|
/** Set the int value of a json_object
|
||||||
|
*
|
||||||
|
* The type of obj is checked to be a json_type_int and 0 is returned
|
||||||
|
* if it is not without any further actions. If type of obj is json_type_int
|
||||||
|
* the obect value is chaned to new_value
|
||||||
|
*
|
||||||
|
* @param obj the json_object instance
|
||||||
|
* @param new_value the value to be set
|
||||||
|
* @returns 1 if value is set correctly, 0 otherwise
|
||||||
|
*/
|
||||||
|
extern int json_object_set_int(struct json_object *obj,int new_value);
|
||||||
|
|
||||||
|
|
||||||
/** Get the int value of a json_object
|
/** Get the int value of a json_object
|
||||||
*
|
*
|
||||||
* The type is coerced to a int64 if the passed object is not a int64.
|
* The type is coerced to a int64 if the passed object is not a int64.
|
||||||
@@ -683,6 +696,19 @@ extern int32_t json_object_get_int(const struct json_object *obj);
|
|||||||
extern int64_t json_object_get_int64(const struct json_object *obj);
|
extern int64_t json_object_get_int64(const struct json_object *obj);
|
||||||
|
|
||||||
|
|
||||||
|
/** Set the int64_t value of a json_object
|
||||||
|
*
|
||||||
|
* The type of obj is checked to be a json_type_int and 0 is returned
|
||||||
|
* if it is not without any further actions. If type of obj is json_type_int
|
||||||
|
* the obect value is chaned to new_value
|
||||||
|
*
|
||||||
|
* @param obj the json_object instance
|
||||||
|
* @param new_value the value to be set
|
||||||
|
* @returns 1 if value is set correctly, 0 otherwise
|
||||||
|
*/
|
||||||
|
extern int json_object_set_int64(struct json_object *obj,int64_t new_value);
|
||||||
|
|
||||||
|
|
||||||
/* double type methods */
|
/* double type methods */
|
||||||
|
|
||||||
/** Create a new empty json_object of type json_type_double
|
/** Create a new empty json_object of type json_type_double
|
||||||
@@ -773,6 +799,20 @@ extern int json_object_double_to_json_string(struct json_object* jso,
|
|||||||
extern double json_object_get_double(const struct json_object *obj);
|
extern double json_object_get_double(const struct json_object *obj);
|
||||||
|
|
||||||
|
|
||||||
|
/** Set the double value of a json_object
|
||||||
|
*
|
||||||
|
* The type of obj is checked to be a json_type_double and 0 is returned
|
||||||
|
* if it is not without any further actions. If type of obj is json_type_double
|
||||||
|
* the obect value is chaned to new_value
|
||||||
|
*
|
||||||
|
* @param obj the json_object instance
|
||||||
|
* @param new_value the value to be set
|
||||||
|
* @returns 1 if value is set correctly, 0 otherwise
|
||||||
|
*/
|
||||||
|
extern int json_object_set_double(struct json_object *obj,double new_value);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* string type methods */
|
/* string type methods */
|
||||||
|
|
||||||
/** Create a new empty json_object of type json_type_string
|
/** Create a new empty json_object of type json_type_string
|
||||||
|
|||||||
Reference in New Issue
Block a user