|
|
@ -60,13 +60,12 @@ int main( void ) { |
|
|
|
char const* firstNameVal = json_getValue( firstName ); |
|
|
|
char const* firstNameVal = json_getValue( firstName ); |
|
|
|
printf( "Fist Name: %s.\n", firstNameVal ); |
|
|
|
printf( "Fist Name: %s.\n", firstNameVal ); |
|
|
|
|
|
|
|
|
|
|
|
json_t const* lastName = json_getProperty( json, "lastName" ); |
|
|
|
char const* lastName = json_getPropertyValue( json, "lastName" ); |
|
|
|
if ( !lastName || JSON_TEXT != json_getType( lastName ) ) { |
|
|
|
if ( !lastName ) { |
|
|
|
puts("Error, the last name property is not found."); |
|
|
|
puts("Error, the last name property is not found."); |
|
|
|
return EXIT_FAILURE; |
|
|
|
return EXIT_FAILURE; |
|
|
|
} |
|
|
|
}
|
|
|
|
char const* lastNameVal = json_getValue( lastName ); |
|
|
|
printf( "Last Name: %s.\n", lastName ); |
|
|
|
printf( "Last Name: %s.\n", lastNameVal ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
json_t const* age = json_getProperty( json, "age" ); |
|
|
|
json_t const* age = json_getProperty( json, "age" ); |
|
|
|
if ( !age || JSON_INTEGER != json_getType( age ) ) { |
|
|
|
if ( !age || JSON_INTEGER != json_getType( age ) ) { |
|
|
@ -85,11 +84,8 @@ int main( void ) { |
|
|
|
json_t const* phone; |
|
|
|
json_t const* phone; |
|
|
|
for( phone = json_getChild( phoneList ); phone != 0; phone = json_getSibling( phone ) ) { |
|
|
|
for( phone = json_getChild( phoneList ); phone != 0; phone = json_getSibling( phone ) ) { |
|
|
|
if ( JSON_OBJ == json_getType( phone ) ) { |
|
|
|
if ( JSON_OBJ == json_getType( phone ) ) { |
|
|
|
json_t const* number = json_getProperty( phone, "number" ); |
|
|
|
char const* phoneNumber = json_getPropertyValue( phone, "number" ); |
|
|
|
if ( number ) { |
|
|
|
if ( phoneNumber ) printf( "Number: %s.\n", phoneNumber ); |
|
|
|
char const* numberVal = json_getValue( number ); |
|
|
|
|
|
|
|
printf( "Number: %s.\n", numberVal ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|