helloJSON/include/json_entities/json_entities.h

65 lines
950 B
C

#ifndef JSON_ENTITIES_H
#define JSON_ENTITIES_H
#include "aliases.h"
#include "dstring.h"
#include <stdbool.h>
typedef struct jentity jentity_t;
typedef struct jcoll jcoll_t;
typedef struct jval jval_t;
typedef struct jpair jpair_t;
typedef enum {
JSON_VALUE_COLLECTION,
JSON_VALUE_STRING,
JSON_VALUE_INTEGER,
JSON_VALUE_DOUBLE,
JSON_VALUE_BOOLEAN,
JSON_VALUE_NULL,
} jval_type;
struct jval {
jval_type type;
union {
jcoll_t *collection;
dstr_t *string;
i64 num_int;
f64 num_dbl;
bool boolean;
};
};
struct jpair {
dstr_t *key;
jval_t value;
};
typedef enum {
JVAL_SINGLE,
JVAL_PAIR,
} jentity_type;
struct jentity {
jentity_type type;
union {
jval_t value;
jpair_t pair;
};
jentity_t *parent;
jentity_t *next;
};
typedef enum {
JCOLL_OBJECT,
JCOLL_ARRAY,
} jcoll_type;
struct jcoll {
u64 size;
jcoll_type type;
jentity_t *first_child;
};
#endif // !JSON_ENTITIES_H