fixed bug in example
This commit is contained in:
+17
-15
@@ -19,25 +19,27 @@ int main()
|
|||||||
// ..error?
|
// ..error?
|
||||||
if(val == NULL)
|
if(val == NULL)
|
||||||
fprintf(stderr, "Failed to parse!\n");
|
fprintf(stderr, "Failed to parse!\n");
|
||||||
|
else
|
||||||
char *name;
|
|
||||||
int age;
|
|
||||||
|
|
||||||
// Now iterate over the fields to get the name
|
|
||||||
// and age.
|
|
||||||
xj_value *child = val->as_object;
|
|
||||||
while(child != NULL)
|
|
||||||
{
|
{
|
||||||
if(!strcmp("name", child->key))
|
char *name;
|
||||||
name = child->as_string;
|
int age;
|
||||||
else
|
|
||||||
age = child->as_int;
|
|
||||||
|
|
||||||
child = child->next;
|
// Now iterate over the fields to get the name
|
||||||
|
// and age.
|
||||||
|
xj_value *child = val->as_object;
|
||||||
|
while(child != NULL)
|
||||||
|
{
|
||||||
|
if(!strcmp("name", child->key))
|
||||||
|
name = child->as_string;
|
||||||
|
else
|
||||||
|
age = child->as_int;
|
||||||
|
|
||||||
|
child = child->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("name: %s, age: %d\n", name, age);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("name: %s, age: %d\n", name, age);
|
|
||||||
|
|
||||||
// Now free everything!
|
// Now free everything!
|
||||||
xj_alloc_del(alloc);
|
xj_alloc_del(alloc);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user