Changeset 606 for branches/PublicaMundi_David-devel/zoo-project/zoo-kernel
- Timestamp:
- Mar 11, 2015, 11:55:20 AM (10 years ago)
- Location:
- branches/PublicaMundi_David-devel/zoo-project/zoo-kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_json.c
r602 r606 33 33 34 34 map* jsontomap(json_object * jobj){ 35 map *m; 35 map *m = (map *) malloc (MAP_SIZE); 36 int i = 0; 36 37 json_object_object_foreach(jobj, key, val){ 37 38 if (json_object_is_type(val, json_type_string)){ 38 addMapToMap(&m,createMap(key,json_object_get_string(val))); 39 if (i==0){ 40 m->name = zStrdup(key); 41 m->value = zStrdup(json_object_get_string(val)); 42 m->next = NULL; 43 i = 1; 44 } 45 else { 46 map *tmp=createMap(key,json_object_get_string(val)); 47 addMapToMap(&m,tmp); 48 freeMap(&tmp); 49 free(tmp); 50 } 39 51 } 40 52 else { 53 fprintf(stderr,"jsontomap not map :%s \n",key); 41 54 /* Attention ce n'est pas une map */ 42 55 return NULL; … … 46 59 } 47 60 48 int jsontomaps(json_object * jobj,maps ** m){ 49 maps *maps_tmp; 61 maps * jsontomaps(json_object * jobj){ 62 maps *mm = (maps *) malloc (MAPS_SIZE); 63 int i =0; 50 64 json_object_object_foreach(jobj, key, val){ 51 maps_tmp = (maps *) malloc (MAPS_SIZE); 52 maps_tmp->content = jsontomap(val); 53 maps_tmp->name = zStrdup(key); 54 addMapsToMaps(m,maps_tmp); 65 if (i ==0){ 66 mm->content = jsontomap(val); 67 mm->name = zStrdup(key); 68 mm->next = NULL; 69 i = 1; 70 } 71 else { 72 maps *maps_tmp; 73 maps_tmp = (maps *) malloc (MAPS_SIZE); 74 maps_tmp->content = jsontomap(val); 75 maps_tmp->name = zStrdup(key); 76 maps_tmp->next = NULL; 77 addMapsToMaps(&mm,maps_tmp); 78 freeMaps(&maps_tmp); 79 free(maps_tmp); 80 maps_tmp = NULL; 81 } 55 82 } 56 return 0;83 return mm; 57 84 } 58 85 -
branches/PublicaMundi_David-devel/zoo-project/zoo-kernel/zoo_json.h
r602 r606 11 11 12 12 map* jsontomap(json_object * jobj); 13 int jsontomaps(json_object * jobj,maps **m);13 maps* jsontomaps(json_object * jobj); 14 14 15 15 #endif
Note: See TracChangeset
for help on using the changeset viewer.