From b0e73ec44dc2693b6be327c01b905193f153df4c Mon Sep 17 00:00:00 2001 From: "Serge A. Zaitsev" Date: Mon, 15 Nov 2010 17:58:50 +0200 Subject: [PATCH] Design: objects and arrays are different types now --- jsmn.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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;