power_play/src/json.h

50 lines
836 B
C

#ifndef JSON_H
#define JSON_H
enum json_type {
JSON_TYPE_NULL,
JSON_TYPE_BOOL,
JSON_TYPE_NUMBER,
JSON_TYPE_STRING,
JSON_TYPE_ARRAY,
JSON_TYPE_OBJECT
};
struct json {
enum json_type type;
struct string key;
struct json *parent;
struct json *next;
struct json *child_first;
struct json *child_last;
union {
struct string string;
f64 number;
b32 boolean;
} value;
};
struct json_error {
struct string msg;
u64 start;
u64 end;
struct json_error *next;
};
struct json_error_list {
u64 count;
struct json_error *first;
struct json_error *last;
};
struct json_parse_result {
struct json *root;
struct json_error_list errors;
};
struct json_parse_result json_from_string(struct arena *arena, struct string src);
#endif