diff --git a/jsmn.c b/jsmn.c index 4e2e405..bdaa49c 100644 --- a/jsmn.c +++ b/jsmn.c @@ -103,14 +103,15 @@ int jsmn_parse(const unsigned char *js, jsontok_t *tokens, size_t num_tokens, in struct jsmn_params params; int r; + unsigned int i; const unsigned char *p; + jsontype_t type; jsontok_t *cur_token; params.num_tokens = num_tokens; params.tokens = tokens; params.errpos = errpos; - unsigned int i; for (i = 0; istart = p - js; break; 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; break;