/* A small JSON reader for the files pic reads as inputs (theme and
* keybindings files): the whole document in, a tree out. Strict RFC 8259
* apart from a leading UTF-8 BOM, which is skipped (Pi's stripBom). */
#ifndef PIC_TUI_MJSON_H
#define PIC_TUI_MJSON_H
#include <stddef.h>
typedef enum { MJ_NULL, MJ_BOOL, MJ_NUM, MJ_STR, MJ_ARR, MJ_OBJ } mj_kind;
typedef struct mj mj;
struct mj {
mj_kind kind;
double num; /* MJ_NUM; MJ_BOOL: 0 or 1 */
char *str; /* MJ_STR */
mj **kids; /* MJ_ARR elements, MJ_OBJ values */
char **keys; /* MJ_OBJ: kids[i]'s key (the last of a repeated key wins in mj_get) */
size_t n;
};
/* The document in s[0..n), or NULL with a message in err (nesting is limited to 32). */
mj *mj_parse(const char *s, size_t n, char *err, size_t errcap);
void mj_free(mj *v);
/* The value of KEY in an object, or NULL. */
const mj *mj_get(const mj *obj, const char *key);
#endif