From cf534d762754860ed5b714974f99acd282d48b3b Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Wed, 8 Apr 2026 13:14:27 +0200 Subject: Restructure into src/{std,json}/ Co-Authored-By: Claude Sonnet 4.6 --- src/json/json.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/json/json.h (limited to 'src/json/json.h') 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 + Vec values; // Vec + 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 + 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); -- cgit v1.3