From daf93a0ebd10e3778ec77a62577543fb11884c83 Mon Sep 17 00:00:00 2001 From: "Serge A. Zaitsev" Date: Tue, 16 Nov 2010 11:56:08 +0200 Subject: [PATCH] Feature: make difference between numbers and other primitives --- jsmn.c | 6 ++++++ jsmn.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/jsmn.c b/jsmn.c index 40bbdc0..2ba4e53 100644 --- a/jsmn.c +++ b/jsmn.c @@ -139,6 +139,12 @@ int jsmn_parse(const unsigned char *js, jsontok_t *tokens, size_t num_tokens, in 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); + r = jsmn_parse_primitive(js, cur_token); + jsmn_assert(r == 0, -2); + 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); diff --git a/jsmn.h b/jsmn.h index 12dd9fd..06f2f51 100644 --- a/jsmn.h +++ b/jsmn.h @@ -7,7 +7,7 @@ * o Array * o String * o Number - * o Primitive: boolean (true/false) or null + * o Other primitive: boolean (true/false) or null */ typedef enum { JSON_OTHER = 0,