diff options
author | Anton Kling <anton@kling.gg> | 2023-10-22 19:50:38 +0200 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2023-10-22 19:50:38 +0200 |
commit | 4e09bca9e34c226b6d7e34b4fa11248405fd988e (patch) | |
tree | 80f156b7940d9d19971395f335530170c69516c7 /userland/json/json.h |
Move everything into a new repo.
Diffstat (limited to 'userland/json/json.h')
-rw-r--r-- | userland/json/json.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/userland/json/json.h b/userland/json/json.h new file mode 100644 index 0000000..642a878 --- /dev/null +++ b/userland/json/json.h @@ -0,0 +1,39 @@ +#ifndef JSON_H +#define JSON_H +#include "hashmap/hashmap.h" +#include <stddef.h> +#include <stdint.h> + +typedef enum JSON_TYPE { + NONE, + STRING, + NUMBER, + OBJECT, + ARRAY, // FIXME + BOOL, + JSON_NULL, +} JSON_TYPE; + +typedef struct JSON_ENTRY { + char *name; + JSON_TYPE type; + void *value; +} JSON_ENTRY; + +typedef struct JSON_OBJECT { + uint64_t size; + JSON_ENTRY *entries; + HashMap *hash_indexes; +} JSON_OBJECT; + +typedef struct JSON_CTX { + JSON_ENTRY global_object; +} JSON_CTX; + +void JSON_Init(JSON_CTX *ctx); +void JSON_Parse(JSON_CTX *ctx, const char *json); +void JSON_extract_fd(JSON_CTX *ctx, int whitespace, int fd); +uint64_t JSON_extract_length(JSON_CTX *ctx, int whitespace); +JSON_ENTRY *JSON_at(JSON_ENTRY *entry, uint64_t i); +JSON_ENTRY *JSON_search_name(JSON_ENTRY *entry, char *name); +#endif |