diff options
Diffstat (limited to 'lib/json_util.c')
| -rw-r--r-- | lib/json_util.c | 41 | 
1 files changed, 23 insertions, 18 deletions
| diff --git a/lib/json_util.c b/lib/json_util.c index ff1d5bb9..b4f5078a 100644 --- a/lib/json_util.c +++ b/lib/json_util.c @@ -27,36 +27,41 @@  #include "json_util.h" -json_value *json_o_get( const json_value *obj, const json_char *name ) -{  +json_value *json_o_get(const json_value *obj, const json_char *name) +{  	int i; -	 -	if( !obj || obj->type != json_object ) + +	if (!obj || obj->type != json_object) {  		return NULL; +	} -	for( i = 0; i < obj->u.object.length; ++ i) -		if( strcmp( obj->u.object.values[i].name, name ) == 0 ) +	for (i = 0; i < obj->u.object.length; ++i) { +		if (strcmp(obj->u.object.values[i].name, name) == 0) {  			return obj->u.object.values[i].value; +		} +	}  	return NULL;  } -const char *json_o_str( const json_value *obj, const json_char *name ) -{  -	json_value *ret = json_o_get( obj, name ); -	 -	if( ret && ret->type == json_string ) +const char *json_o_str(const json_value *obj, const json_char *name) +{ +	json_value *ret = json_o_get(obj, name); + +	if (ret && ret->type == json_string) {  		return ret->u.string.ptr; -	else +	} else {  		return NULL; +	}  } -char *json_o_strdup( const json_value *obj, const json_char *name ) +char *json_o_strdup(const json_value *obj, const json_char *name)  { -	json_value *ret = json_o_get( obj, name ); -	 -	if( ret && ret->type == json_string && ret->u.string.ptr ) -		return g_memdup( ret->u.string.ptr, ret->u.string.length + 1 ); -	else +	json_value *ret = json_o_get(obj, name); + +	if (ret && ret->type == json_string && ret->u.string.ptr) { +		return g_memdup(ret->u.string.ptr, ret->u.string.length + 1); +	} else {  		return NULL; +	}  } | 
