blob: 642a87852dfe6b8f8c62a806ae4ecd41323f935d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
|