|
|
|
@ -129,35 +129,35 @@ int jsmn_parse(const unsigned char *js, jsontok_t *tokens, size_t num_tokens, in
|
|
|
|
|
case '{': case '[':
|
|
|
|
|
type = (*p == '{' ? JSON_OBJECT : JSON_ARRAY);
|
|
|
|
|
cur_token = jsmn_token_start(¶ms, type, p - js);
|
|
|
|
|
jsmn_assert(cur_token != NULL, -1);
|
|
|
|
|
jsmn_assert(cur_token != NULL, JSMN_ERROR_NOMEM);
|
|
|
|
|
break;
|
|
|
|
|
case '}' : case ']':
|
|
|
|
|
type = (*p == '}' ? JSON_OBJECT : JSON_ARRAY);
|
|
|
|
|
cur_token = jsmn_token_end(¶ms, type, p - js + 1);
|
|
|
|
|
jsmn_assert(cur_token != NULL, -1);
|
|
|
|
|
jsmn_assert(cur_token != NULL, JSMN_ERROR_PART);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '-': case '0': case '1' : case '2': case '3' : case '4':
|
|
|
|
|
case '5': case '6': case '7' : case '8': case '9':
|
|
|
|
|
cur_token = jsmn_token_start(¶ms, JSON_NUMBER, p - js);
|
|
|
|
|
jsmn_assert(cur_token != NULL, -1);
|
|
|
|
|
jsmn_assert(cur_token != NULL, JSMN_ERROR_NOMEM);
|
|
|
|
|
r = jsmn_parse_primitive(js, cur_token);
|
|
|
|
|
jsmn_assert(r == 0, -2);
|
|
|
|
|
jsmn_assert(r == 0, JSMN_ERROR_INVAL);
|
|
|
|
|
p = &js[cur_token->end] - 1;
|
|
|
|
|
break;
|
|
|
|
|
case 't': case 'f': case 'n' :
|
|
|
|
|
cur_token = jsmn_token_start(¶ms, JSON_OTHER, p - js);
|
|
|
|
|
jsmn_assert(cur_token != NULL, -1);
|
|
|
|
|
jsmn_assert(cur_token != NULL, JSMN_ERROR_NOMEM);
|
|
|
|
|
r = jsmn_parse_primitive(js, cur_token);
|
|
|
|
|
jsmn_assert(r == 0, -2);
|
|
|
|
|
jsmn_assert(r == 0, JSMN_ERROR_INVAL);
|
|
|
|
|
p = &js[cur_token->end] - 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '\"':
|
|
|
|
|
cur_token = jsmn_token_start(¶ms, JSON_STRING, p - js);
|
|
|
|
|
jsmn_assert(cur_token != NULL, -1);
|
|
|
|
|
jsmn_assert(cur_token != NULL, JSMN_ERROR_NOMEM);
|
|
|
|
|
r = jsmn_parse_string(js, cur_token);
|
|
|
|
|
jsmn_assert(r == 0, -2);
|
|
|
|
|
jsmn_assert(r == 0, JSMN_ERROR_INVAL);
|
|
|
|
|
p = &js[cur_token->end];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
@ -165,7 +165,7 @@ int jsmn_parse(const unsigned char *js, jsontok_t *tokens, size_t num_tokens, in
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
jsmn_assert(0, -1); /* Assert always fails */
|
|
|
|
|
jsmn_return(JSMN_ERROR_INVAL);
|
|
|
|
|
}
|
|
|
|
|
p++;
|
|
|
|
|
}
|
|
|
|
|