mirror of
https://github.com/rafagafe/tiny-json.git
synced 2024-11-16 19:35:29 +00:00
Refactor examples
This commit is contained in:
parent
a5402595cb
commit
e11cf572ef
@ -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…
Reference in New Issue
Block a user