#ifndef BEACHCOMBER_JSON_H
#define BEACHCOMBER_JSON_H
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
JSON_NULL = 0,
JSON_BOOL = 1,
JSON_INT = 2,
JSON_FLOAT = 3,
JSON_STRING = 4,
JSON_ARRAY = 5,
JSON_OBJECT = 6,
} json_type_t;
typedef struct json_node {
json_type_t type;
char *key;
union {
int boolean;
int64_t integer;
double floating;
char *string;
} val;
struct json_node *children;
size_t n_children;
struct json_node *next;
} json_node_t;
json_node_t *json_parse(const char *src);
void json_free(json_node_t *node);
json_node_t *json_get(const json_node_t *node, const char *key);
const char *json_as_str (const json_node_t *node);
int64_t json_as_int (const json_node_t *node, int *ok);
double json_as_float(const json_node_t *node, int *ok);
int json_as_bool (const json_node_t *node, int *ok);
const char *json_type_name(json_type_t type);
#ifdef __cplusplus
}
#endif
#endif