Refactor examples

This commit is contained in:
rafagafe 2017-04-02 03:45:59 +02:00
parent a5402595cb
commit e11cf572ef
2 changed files with 6 additions and 10 deletions

View File

@ -29,7 +29,7 @@
/* Parser a json string. */
int main( void ) {
char const* msg = "{\n"
char str[] = "{\n"
"\t\"firstName\": \"Bidhan\",\n"
"\t\"lastName\": \"Chatterjee\",\n"
"\t\"age\": 40,\n"
@ -44,11 +44,9 @@ int main( void ) {
"\t\t{ \"type\": \"fax\", \"number\": \"91-342-2567692\" }\n"
"\t]\n"
"}\n";
char aux[512];
strcpy( aux, msg );
puts( aux );
puts( str );
json_t mem[32];
json_t const* json = json_create( aux, mem, sizeof mem / sizeof *mem );
json_t const* json = json_create( str, mem, sizeof mem / sizeof *mem );
if ( !json ) {
puts("Error json create.");
return EXIT_FAILURE;

View File

@ -86,7 +86,7 @@ static void print( json_t const* json ) {
/* Parser a json string. */
int main( void ) {
char const* msg = "{\n"
char str[] = "{\n"
"\t\"firstName\": \"Bidhan\",\n"
"\t\"lastName\": \"Chatterjee\",\n"
"\t\"age\": 40,\n"
@ -101,11 +101,9 @@ int main( void ) {
"\t\t{ \"type\": \"fax\", \"number\": \"91-342-2567692\" }\n"
"\t]\n"
"}\n";
char aux[512];
strcpy( aux, msg );
puts( aux );
puts( str );
json_t mem[32];
json_t const* json = json_create( aux, mem, sizeof mem / sizeof *mem );
json_t const* json = json_create( str, mem, sizeof mem / sizeof *mem );
if ( !json ) {
puts("Error json create.");
return EXIT_FAILURE;