|
|
@ -103,14 +103,15 @@ int jsmn_parse(const unsigned char *js, jsontok_t *tokens, size_t num_tokens, in
|
|
|
|
struct jsmn_params params;
|
|
|
|
struct jsmn_params params;
|
|
|
|
|
|
|
|
|
|
|
|
int r;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
unsigned int i;
|
|
|
|
const unsigned char *p;
|
|
|
|
const unsigned char *p;
|
|
|
|
|
|
|
|
jsontype_t type;
|
|
|
|
jsontok_t *cur_token;
|
|
|
|
jsontok_t *cur_token;
|
|
|
|
|
|
|
|
|
|
|
|
params.num_tokens = num_tokens;
|
|
|
|
params.num_tokens = num_tokens;
|
|
|
|
params.tokens = tokens;
|
|
|
|
params.tokens = tokens;
|
|
|
|
params.errpos = errpos;
|
|
|
|
params.errpos = errpos;
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i<num_tokens; i++) {
|
|
|
|
for (i = 0; i<num_tokens; i++) {
|
|
|
|
tokens[i].start = tokens[i].end = -1;
|
|
|
|
tokens[i].start = tokens[i].end = -1;
|
|
|
|
tokens[i].type = JSON_OTHER;
|
|
|
|
tokens[i].type = JSON_OTHER;
|
|
|
@ -119,11 +120,13 @@ int jsmn_parse(const unsigned char *js, jsontok_t *tokens, size_t num_tokens, in
|
|
|
|
for (p = js; *p != '\0'; ) {
|
|
|
|
for (p = js; *p != '\0'; ) {
|
|
|
|
switch (*p) {
|
|
|
|
switch (*p) {
|
|
|
|
case '{': case '[':
|
|
|
|
case '{': case '[':
|
|
|
|
cur_token = jsmn_token_start(¶ms, JSON_OBJECT, p - js);
|
|
|
|
type = (*p == '{' ? JSON_OBJECT : JSON_ARRAY);
|
|
|
|
|
|
|
|
cur_token = jsmn_token_start(¶ms, type, p - js);
|
|
|
|
cur_token->start = p - js;
|
|
|
|
cur_token->start = p - js;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case '}' : case ']':
|
|
|
|
case '}' : case ']':
|
|
|
|
cur_token = jsmn_token_end(¶ms, JSON_OBJECT, p - js + 1);
|
|
|
|
type = (*p == '}' ? JSON_OBJECT : JSON_ARRAY);
|
|
|
|
|
|
|
|
cur_token = jsmn_token_end(¶ms, type, p - js + 1);
|
|
|
|
cur_token->end = p - js + 1;
|
|
|
|
cur_token->end = p - js + 1;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|