Add JSON API

This commit is contained in:
Sergey Lyubka committed 2022-06-09 17:17:33 +01:00
1 parent b73115c002
commit 106662b1d7
9 files changed
+687 -1

No files matched your search

+18
View File
@@ -726,6 +726,7 @@ int mg_check_ip_acl(struct mg_str acl, uint32_t remote_ip);
int64_t mg_to64(struct mg_str str);
uint64_t mg_tou64(struct mg_str str);
size_t mg_lld(char *buf, int64_t val, bool is_signed, bool is_hex);
double mg_atod(const char *buf, int len, int *numlen);
@@ -1303,6 +1304,23 @@ struct mip_ipcfg {
void mip_init(struct mg_mgr *, struct mip_ipcfg *, struct mip_driver *);
#ifndef MG_JSON_MAX_DEPTH
#define MG_JSON_MAX_DEPTH 30
#endif
// Error return values - negative. Successful returns are >= 0
enum { MG_JSON_TOO_DEEP = -1, MG_JSON_INVALID = -2, MG_JSON_NOT_FOUND = -3 };
int mg_json_get(const char *buf, int len, const char *path, int *toklen);
bool mg_json_get_num(struct mg_str json, const char *path, double *v);
bool mg_json_get_bool(struct mg_str json, const char *path, bool *v);
char *mg_json_get_str(struct mg_str json, const char *path);
char *mg_json_get_hex(struct mg_str json, const char *path);
#ifdef __cplusplus
}
#endif