From 4e09bca9e34c226b6d7e34b4fa11248405fd988e Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Sun, 22 Oct 2023 19:50:38 +0200 Subject: Move everything into a new repo. --- userland/json/json.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 userland/json/json.h (limited to 'userland/json/json.h') 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 +#include + +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 -- cgit v1.2.3