json-parser.h revision e0ba54c7f985fc403b41c6e36d6a7f44908b23f0
45312f52ff3a3d4c137447be4c7556500c2f8bf2Timo Sirainen#ifndef JSON_PARSER_H
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainen#define JSON_PARSER_H
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainen
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainenenum json_type {
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainen JSON_TYPE_OBJECT_KEY,
687d1dee0e92229232aa8be416897b640df67d07Timo Sirainen JSON_TYPE_STRING,
65988f5a8abed57e9894fec77105941e046d3490Timo Sirainen JSON_TYPE_NUMBER,
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainen JSON_TYPE_TRUE,
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainen JSON_TYPE_FALSE,
687d1dee0e92229232aa8be416897b640df67d07Timo Sirainen JSON_TYPE_NULL
dabb4cec4cf9bdb34013de682b08f1284cfb670fTimo Sirainen};
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainen
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainen/* A really simple JSON parser, which for now only needs to be able to parse
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainen a single { key: value, .. } object. */
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainenstruct json_parser *
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainenjson_parser_init(const unsigned char *data, unsigned int len);
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainenint json_parser_deinit(struct json_parser **parser, const char **error_r);
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainen
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainenbool json_parse_next(struct json_parser *parser, enum json_type *type_r,
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainen const char **value_r);
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainen
050975ee630c761ab237fce7b8f84fe189bb02d2Timo Sirainen#endif
64510d2cc23a79d2142030bf5bade44baa490db3Timo Sirainen