diff --git a/clib/jlexer.c b/clib/jlexer.c index 3a89a36..205f162 100644 --- a/clib/jlexer.c +++ b/clib/jlexer.c @@ -174,9 +174,13 @@ int jlexer_gettoken(jlexer_t * lexer, char* token) { switch (type) { case JLEXTYPE_EOF: case JLEXTYPE_WORDL:{ - token[lexer->tokpos++] = '\0'; - lexer->context = JLEXCONT_UNDEF; - return JLEXTOK_WORD; + if (lexer->tokpos > 0 && token[lexer->tokpos - 1] == '\\') { + lexer->tokpos--; + } else { + token[lexer->tokpos++] = '\0'; + lexer->context = JLEXCONT_UNDEF; + return JLEXTOK_WORD; + } } } lexer->context = newcontext; @@ -198,7 +202,6 @@ int jlexer_gettoken(jlexer_t * lexer, char* token) { if (token[i] == 'E' || token[i] == 'e' || token[i] == '.') { return JLEXTOK_FLOAT; } - } return JLEXTOK_INTEG; } diff --git a/clib/jparser.c b/clib/jparser.c index 4287f7f..3807a13 100644 --- a/clib/jparser.c +++ b/clib/jparser.c @@ -39,6 +39,7 @@ int jparser_parse_array(jparser_t * parser, char* arrname) { int pos = 0; + while ((type = jlexer_gettoken(lex, token)) != JLEXTOK_END) { log_debug("pos %d tok 0x%02x: %s\n", pos, type, token); diff --git a/clib/test.json b/clib/test.json index 2af663e..6601441 100644 --- a/clib/test.json +++ b/clib/test.json @@ -1 +1 @@ -{"id":-123, "name": "qwerty", "size": -12345E3, "exists": true, "intarr": [ 11E1, 12, 13 ]} +{"id":-123, "name": "qwerty", "size": -12345E3, "exists": true, "intarr": [ 11E1, 12, 13 ], "a\"b.c": 567.123 }