|
@@ -42,7 +42,7 @@ bool parse_person(Jimp *jimp, Person *p)
|
|
|
bool parse_people(Jimp *jimp, People *ps)
|
|
|
{
|
|
|
if (!jimp_array_begin(jimp)) return false;
|
|
|
- while (jimp_array_has_items(jimp)) {
|
|
|
+ while (jimp_array_item(jimp)) {
|
|
|
Person p = {0};
|
|
|
if (!parse_person(jimp, &p)) return false;
|
|
|
da_append(ps, p);
|
|
@@ -68,12 +68,12 @@ typedef struct {
|
|
|
|
|
|
int main()
|
|
|
{
|
|
|
- const char *file_path = "profile.json";
|
|
|
- // const char *path = "numbers.json";
|
|
|
- // const char *path = "profiles.json";
|
|
|
- // const char *path = "empty.json";
|
|
|
- // const char *path = "one.json";
|
|
|
- // const char *path = "database.json";
|
|
|
+ // const char *file_path = "profile.json";
|
|
|
+ // const char *file_path = "numbers.json";
|
|
|
+ // const char *file_path = "profiles.json";
|
|
|
+ // const char *file_path = "empty.json";
|
|
|
+ // const char *file_path = "one.json";
|
|
|
+ const char *file_path = "database.json";
|
|
|
String_Builder sb = {0};
|
|
|
if (!read_entire_file(file_path, &sb)) return 1;
|
|
|
Jimp jimp = {
|
|
@@ -82,20 +82,15 @@ int main()
|
|
|
static char string_store[1024];
|
|
|
stb_c_lexer_init(&jimp.l, sb.items, sb.items + sb.count, string_store, sizeof(string_store));
|
|
|
|
|
|
- Person p = {0};
|
|
|
- if (!parse_person(&jimp, &p)) return 1;
|
|
|
- print_person(&p);
|
|
|
-
|
|
|
- /*
|
|
|
People ps = {0};
|
|
|
Numbers xs = {0};
|
|
|
if (!jimp_object_begin(&jimp)) return 1;
|
|
|
while (jimp_object_member(&jimp)) {
|
|
|
- if (strcmp(jimp.key, "profile") == 0) {
|
|
|
+ if (strcmp(jimp.member, "profile") == 0) {
|
|
|
if (!parse_people(&jimp, &ps)) return 1;
|
|
|
- } else if (strcmp(jimp.key, "number") == 0) {
|
|
|
+ } else if (strcmp(jimp.member, "number") == 0) {
|
|
|
if (!jimp_array_begin(&jimp)) return 1;
|
|
|
- while (jimp_array_has_items(&jimp)) {
|
|
|
+ while (jimp_array_item(&jimp)) {
|
|
|
long x = 0;
|
|
|
jimp_number(&jimp, &x);
|
|
|
da_append(&xs, x);
|
|
@@ -117,7 +112,6 @@ int main()
|
|
|
printf("%ld ", *x);
|
|
|
}
|
|
|
printf("\n");
|
|
|
- */
|
|
|
|
|
|
return 0;
|
|
|
}
|