diff dowa/dowa.h @ 182:d6ab5921fedc

Merging in changes I had on my mac related to JSON parser and MPC endpoints.
author June Park <parkjune1995@gmail.com>
date Fri, 23 Jan 2026 21:09:49 -0800
parents a2720eac50ce
children
line wrap: on
line diff
--- a/dowa/dowa.h	Thu Jan 22 21:23:17 2026 -0800
+++ b/dowa/dowa.h	Fri Jan 23 21:09:49 2026 -0800
@@ -206,6 +206,35 @@
 DLAPI char       *Dowa_String_Find_Char(const char *p_from, int c, int32 from_length);
 DLAPI char       *Dowa_String_UUID(uint32 seed, void *buffer);
 
+// --- JSON --- //
+typedef enum {
+  DOWA_JSON_NULL,
+  DOWA_JSON_BOOL,
+  DOWA_JSON_NUMBER,
+  DOWA_JSON_STRING,
+  DOWA_JSON_ARRAY,
+  DOWA_JSON_OBJECT
+} Dowa_JSON_Type;
+
+typedef struct Dowa_JSON_Value {
+  Dowa_JSON_Type type;
+  union {
+    boolean bool_val;
+    double  num_val;
+    char   *str_val;
+    struct Dowa_JSON_Value *array_val;  // Dowa array of Dowa_JSON_Value
+    void   *object_val;                 // Dowa_JSON_Entry* hashmap
+  };
+} Dowa_JSON_Value;
+
+typedef Dowa_KV(char*, Dowa_JSON_Value) Dowa_JSON_Entry;
+
+DLAPI Dowa_JSON_Value  Dowa_JSON_Parse(const char *json, int32 length, Dowa_Arena *p_arena);
+DLAPI Dowa_JSON_Value *Dowa_JSON_Get(Dowa_JSON_Entry *map, const char *key);
+DLAPI char            *Dowa_JSON_Get_String(Dowa_JSON_Entry *map, const char *key);
+DLAPI double           Dowa_JSON_Get_Number(Dowa_JSON_Entry *map, const char *key);
+DLAPI boolean          Dowa_JSON_Get_Bool(Dowa_JSON_Entry *map, const char *key);
+
 // --- Math --- //
 DLAPI uint32      Dowa_Math_Random_Uint32(uint32 seed_number);