diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-04-08 13:14:27 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-04-08 13:15:01 +0200 |
| commit | cf534d762754860ed5b714974f99acd282d48b3b (patch) | |
| tree | bf22341cedfb50ee7bcd4e15f85add2329783f31 /src/json/json.h | |
| parent | 630fcb1846aed16b9ab62bcf700f668883f4521f (diff) | |
Restructure into src/{std,json}/
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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); |
