36 #define SPECIAL_CHARS "{}[]:,\" \n\r\t" 37 #define OPEN_CURLY '{' 38 #define CLSE_CURLY '}' 39 #define OPEN_SQUARE '[' 40 #define CLSE_SQUARE ']' 42 #define DBLE_QUOTE '\"' 44 #define MIN_AFTER_TOKEN 6 45 #define NEXT_CHAR(p, l) p++; l--; 46 #define SKIP_TO_CHAR(p, l, c) do { NEXT_CHAR(p, l) } while (*p != c && l != 0) 47 #define SKIP_DATA(pc, lt) while (lt != 0 && strchr(special_chars, *pc) == NULL) { NEXT_CHAR(pc, lt) } 48 #define SKIP_SPACES(pc, lt) while (lt != 0 && (*pc == ' ' || *pc == '\n' || *pc == '\r' || *pc == '\t')) { NEXT_CHAR(pc, lt) } 63 static unsigned int JsonArrayCount(
char *pData,
U32BIT Left );
65 static void ParseJsonArrayObject(
char **ppData,
U32BIT *pLeft,
80 char *in_data = (
char *)data;
83 return ParseJsonObject( &in_data, &left, members, usr );
92 assert( p_str != NULL );
131 char *pData = *ppData;
139 while (pMmber->
tk_len != 0 &&
150 if (*pData ==
':' && left > 1)
157 if (*pData >=
'0' && *pData <=
'9')
163 value += *pData -
'0';
166 while (*pData >=
'0' && *pData <=
'9' && left != 0);
167 if (pMmber->
u.
ptr != NULL)
169 switch (pMmber->
type)
175 (void)(pMmber->
u.
cb_func)( value, NULL, usr );
190 char *pStr = pData + 1;
198 if (pMmber->
u.
ptr != NULL)
200 value = (
unsigned int)(pData - pStr);
201 switch (pMmber->
type)
209 (void)(pMmber->
u.
cb_func)( value, pStr, usr );
218 memcpy(pAstr, pStr, value);
219 assert(pAstr[value] == 0);
228 (void)(pMmber->
u.
cb_func)( value, pAstr, usr );
253 switch (pMmber->
type)
256 ParseJsonArrayObject( &pData, &left, pMmber, usr );
284 state = ParseJsonObject( &pData, &left, pMmber->
pChildren, usr );
308 char *pData = *ppData;
327 state = ParseJsonMember( &pData, &left, members, usr );
385 static unsigned int JsonArrayCount(
char *pData,
U32BIT left )
387 unsigned int count = 0;
413 if (*pData >=
'0' && *pData <=
'9')
440 static void ParseJsonArrayObject(
char **ppData,
U32BIT *pLeft,
444 char *pData = *ppData;
450 usr = (pMmber->
u.
cb_func)( JsonArrayCount(pData, left), NULL, usr );
#define SKIP_DATA(pc, lt)
#define JSON_VALUE_FINISH
#define SKIP_TO_CHAR(p, l, c)
void JSON_FreeStrArray(S_STRING **pp_str)
union s_json_members::@9 u
unsigned char * STR_DataAlloc(unsigned int size)
E_JSON_STATE JSON_Parse(U8BIT *data, U32BIT size, const S_JSON_MEMBERS *members, void *usr)
#define SKIP_SPACES(pc, lt)
void STR_DataFree(unsigned char *data, unsigned int size)
void JSON_FreeUintArray(U32BIT *p_uint)
Mheg5 logging and debug printing.
void JSON_FreeAstring(S_STRING *p_str)
string parsing utility functions described by the [JSON] schema
const struct s_json_members * pChildren