5502879a5b
This is very much still work in progress and much more will change before the final 2.0.0 Some APIs have changed. New libraries have been added. LittleFS included. Co-authored-by: Seon Rozenblum <seonr@3sprockets.com> Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Mike Dunston <m_dunston@comcast.net> Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com> Co-authored-by: Seon Rozenblum <seonr@3sprockets.com> Co-authored-by: microDev <70126934+microDev1@users.noreply.github.com> Co-authored-by: tobozo <tobozo@users.noreply.github.com> Co-authored-by: bobobo1618 <bobobo1618@users.noreply.github.com> Co-authored-by: lorol <lorolouis@gmail.com> Co-authored-by: geeksville <kevinh@geeksville.com> Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net> Co-authored-by: Sweety <switi.mhaiske@espressif.com> Co-authored-by: Loick MAHIEUX <loick111@gmail.com> Co-authored-by: Larry Bernstone <lbernstone@gmail.com> Co-authored-by: Valerii Koval <valeros@users.noreply.github.com> Co-authored-by: 快乐的我531 <2302004040@qq.com> Co-authored-by: chegewara <imperiaonline4@gmail.com> Co-authored-by: Clemens Kirchgatterer <clemens@1541.org> Co-authored-by: Aron Rubin <aronrubin@gmail.com> Co-authored-by: Pete Lewis <601236+lewispg228@users.noreply.github.com>
62 lines
2.2 KiB
C
Executable File
62 lines
2.2 KiB
C
Executable File
/* Code taken from: https://github.com/shahpiyushv/json_parser */
|
|
#ifndef _JSON_PARSER_H_
|
|
#define _JSON_PARSER_H_
|
|
|
|
#include <jsmn-changed.h>
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
#define OS_SUCCESS 0
|
|
#define OS_FAIL -1
|
|
|
|
typedef _jsmn_parser json_parser_t;
|
|
typedef _jsmntok_t json_tok_t;
|
|
|
|
typedef struct {
|
|
json_parser_t parser;
|
|
char *js;
|
|
json_tok_t *tokens;
|
|
json_tok_t *cur;
|
|
int num_tokens;
|
|
} jparse_ctx_t;
|
|
|
|
int json_parse_start(jparse_ctx_t *jctx, char *js, int len);
|
|
int json_parse_end(jparse_ctx_t *jctx);
|
|
|
|
int json_obj_get_array(jparse_ctx_t *jctx, char *name, int *num_elem);
|
|
int json_obj_leave_array(jparse_ctx_t *jctx);
|
|
int json_obj_get_object(jparse_ctx_t *jctx, char *name);
|
|
int json_obj_leave_object(jparse_ctx_t *jctx);
|
|
int json_obj_get_bool(jparse_ctx_t *jctx, char *name, bool *val);
|
|
int json_obj_get_int(jparse_ctx_t *jctx, char *name, int *val);
|
|
int json_obj_get_int64(jparse_ctx_t *jctx, char *name, int64_t *val);
|
|
int json_obj_get_float(jparse_ctx_t *jctx, char *name, float *val);
|
|
int json_obj_get_string(jparse_ctx_t *jctx, char *name, char *val, int size);
|
|
int json_obj_get_strlen(jparse_ctx_t *jctx, char *name, int *strlen);
|
|
int json_obj_get_object_str(jparse_ctx_t *jctx, char *name, char *val, int size);
|
|
int json_obj_get_object_strlen(jparse_ctx_t *jctx, char *name, int *strlen);
|
|
int json_obj_get_array_str(jparse_ctx_t *jctx, char *name, char *val, int size);
|
|
int json_obj_get_array_strlen(jparse_ctx_t *jctx, char *name, int *strlen);
|
|
|
|
int json_arr_get_array(jparse_ctx_t *jctx, uint32_t index);
|
|
int json_arr_leave_array(jparse_ctx_t *jctx);
|
|
int json_arr_get_object(jparse_ctx_t *jctx, uint32_t index);
|
|
int json_arr_leave_object(jparse_ctx_t *jctx);
|
|
int json_arr_get_bool(jparse_ctx_t *jctx, uint32_t index, bool *val);
|
|
int json_arr_get_int(jparse_ctx_t *jctx, uint32_t index, int *val);
|
|
int json_arr_get_int64(jparse_ctx_t *jctx, uint32_t index, int64_t *val);
|
|
int json_arr_get_float(jparse_ctx_t *jctx, uint32_t index, float *val);
|
|
int json_arr_get_string(jparse_ctx_t *jctx, uint32_t index, char *val, int size);
|
|
int json_arr_get_strlen(jparse_ctx_t *jctx, uint32_t index, int *strlen);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _JSON_PARSER_H_ */
|