- Timestamp:
- 2012-11-08T22:38:20Z (12 years ago)
- Branches:
- master
- Children:
- fb351ce
- Parents:
- 0688e99
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/json_util.c
r0688e99 r8e3b7ac 27 27 #include "json_util.h" 28 28 29 json_value *json_o_get( json_value *obj,json_char *name )29 json_value *json_o_get( const json_value *obj, const json_char *name ) 30 30 { 31 31 int i; … … 41 41 } 42 42 43 const char *json_o_str( json_value *obj,json_char *name )43 const char *json_o_str( const json_value *obj, const json_char *name ) 44 44 { 45 45 json_value *ret = json_o_get( obj, name ); 46 46 47 if( ret )47 if( ret && ret->type == json_string ) 48 48 return ret->u.string.ptr; 49 49 else 50 50 return NULL; 51 51 } 52 53 char *json_o_strdup( const json_value *obj, const json_char *name ) 54 { 55 json_value *ret = json_o_get( obj, name ); 56 57 if( ret && ret->type == json_string && ret->u.string.ptr ) 58 return g_memdup( ret->u.string.ptr, ret->u.string.length + 1 ); 59 else 60 return NULL; 61 } -
lib/json_util.h
r0688e99 r8e3b7ac 24 24 #include "json.h" 25 25 26 json_value *json_o_get( json_value *obj, json_char *name ); 27 const char *json_o_str( json_value *obj, json_char *name ); 26 #define JSON_O_FOREACH(o, k, v) \ 27 char *k; json_value *v; int __i; \ 28 for( __i = 0; k = (o)->u.object.values[__i].name, \ 29 v = (o)->u.object.values[__i].value, \ 30 __i < (o)->u.object.length; __i ++ ) 31 32 json_value *json_o_get( const json_value *obj, const json_char *name ); 33 const char *json_o_str( const json_value *obj, const json_char *name ); 34 char *json_o_strdup( const json_value *obj, const json_char *name );
Note: See TracChangeset
for help on using the changeset viewer.