Refactor examples

pull/1/head
rafagafe 8 years ago
parent a5402595cb
commit e11cf572ef
  1. 8
      example-01.c
  2. 8
      example-02.c

@ -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;

@ -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;

Loading…
Cancel
Save