@@ -42,7 +42,7 @@ bool parse_person(Jimp *jimp, Person *p)
42
42
bool parse_people (Jimp * jimp , People * ps )
43
43
{
44
44
if (!jimp_array_begin (jimp )) return false;
45
- while (jimp_array_has_items (jimp )) {
45
+ while (jimp_array_item (jimp )) {
46
46
Person p = {0 };
47
47
if (!parse_person (jimp , & p )) return false;
48
48
da_append (ps , p );
@@ -68,12 +68,12 @@ typedef struct {
68
68
69
69
int main ()
70
70
{
71
- const char * file_path = "profile.json" ;
72
- // const char *path = "numbers.json";
73
- // const char *path = "profiles.json";
74
- // const char *path = "empty.json";
75
- // const char *path = "one.json";
76
- // const char *path = "database.json";
71
+ // const char *file_path = "profile.json";
72
+ // const char *file_path = "numbers.json";
73
+ // const char *file_path = "profiles.json";
74
+ // const char *file_path = "empty.json";
75
+ // const char *file_path = "one.json";
76
+ const char * file_path = "database.json" ;
77
77
String_Builder sb = {0 };
78
78
if (!read_entire_file (file_path , & sb )) return 1 ;
79
79
Jimp jimp = {
@@ -82,20 +82,15 @@ int main()
82
82
static char string_store [1024 ];
83
83
stb_c_lexer_init (& jimp .l , sb .items , sb .items + sb .count , string_store , sizeof (string_store ));
84
84
85
- Person p = {0 };
86
- if (!parse_person (& jimp , & p )) return 1 ;
87
- print_person (& p );
88
-
89
- /*
90
85
People ps = {0 };
91
86
Numbers xs = {0 };
92
87
if (!jimp_object_begin (& jimp )) return 1 ;
93
88
while (jimp_object_member (& jimp )) {
94
- if (strcmp(jimp.key , "profile") == 0) {
89
+ if (strcmp (jimp .member , "profile" ) == 0 ) {
95
90
if (!parse_people (& jimp , & ps )) return 1 ;
96
- } else if (strcmp(jimp.key , "number") == 0) {
91
+ } else if (strcmp (jimp .member , "number" ) == 0 ) {
97
92
if (!jimp_array_begin (& jimp )) return 1 ;
98
- while (jimp_array_has_items (&jimp)) {
93
+ while (jimp_array_item (& jimp )) {
99
94
long x = 0 ;
100
95
jimp_number (& jimp , & x );
101
96
da_append (& xs , x );
@@ -117,7 +112,6 @@ int main()
117
112
printf ("%ld " , * x );
118
113
}
119
114
printf ("\n" );
120
- */
121
115
122
116
return 0 ;
123
117
}
0 commit comments