add json parsing of lists and maps

This commit is contained in:
Felix Van der Jeugt 2022-11-08 23:31:00 +01:00
parent 7471093f67
commit 025c8125fa
No known key found for this signature in database
GPG key ID: 58B209295023754D
16 changed files with 210 additions and 20 deletions

View file

@ -104,14 +104,16 @@ Gamestate *read_gamestate() {
}
void free_gamestate(Gamestate *this) {
fold_list(this->planets, NULL, free_listitem);
free_list(this->planets);
fold_list(this->expeditions, NULL, free_listitem);
free_list(this->expeditions);
free(this);
}
int main(int argc, char **argv) {
Json * json = json_parse(stdin);
Gamestate *gamestate;
/*Gamestate *gamestate;
SortedMap *test;
gamestate = read_gamestate();
@ -124,7 +126,11 @@ int main(int argc, char **argv) {
test = put_map(test, "awer", "qwer");
printf("%s\n", (char *) get_map(test, "awer"));
print_map(test);
free_map(test);
free_map(test); */
json_print(json, stdout);
json_free(json);
json = json_parse(stdin);
json_print(json, stdout);
json_free(json);
return 0;