diff options
Diffstat (limited to 'src/json/json.h')
| -rw-r--r-- | src/json/json.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/json/json.h b/src/json/json.h new file mode 100644 index 0000000..15b3fca --- /dev/null +++ b/src/json/json.h @@ -0,0 +1,34 @@ +#pragma once +#include "../std/memory.h" +#include "../std/str.h" +#include "../std/vec.h" + +typedef struct { + Vec keys; // Vec<Str> + Vec values; // Vec<JSON> + size len; +} JSONObject; +typedef enum { + JSON_NULL, + JSON_BOOL, + JSON_INTEGER, + JSON_FLOAT, + JSON_STRING, + JSON_ARRAY, + JSON_OBJECT +} JSONType; +typedef struct { + JSONType type; + union { + bool boolean; + i32 integer; + f32 floating; + Vec array; // Vec<JSON> + StrView string; + JSONObject object; + } as; +} JSON; +JSON *JSONObject_get(JSONObject obj, Str key); +i32 JSON_fprint(FILE *w, JSON json); +JSON JSON_parse(Arena *a, byte *src, uptr len); +JSON JSON_Int(Arena *a, i32 val); |
