add json printing and parsing (of strings)

This commit is contained in:
Felix Van der Jeugt 2022-11-02 00:05:01 +01:00
parent 563b1b0c5a
commit a13c6ecb3a
No known key found for this signature in database
GPG key ID: 58B209295023754D
6 changed files with 277 additions and 81 deletions

21
json.h Normal file
View file

@ -0,0 +1,21 @@
#ifndef JSON_HEADER
#define JSON_HEADER
#include "sortedmap.h"
#include "arraylist.h"
enum jsontype { BOOLEAN, STRING, NUMBER, LIST, MAP };
typedef struct json {
enum jsontype type;
union {
int boolean;
char * string;
double number;
ArrayList * list;
SortedMap * map;
} value;
} Json;
Json * json_parse(FILE *stream);
void json_print(Json *this, FILE *stream);
void json_free(Json *this);
#endif