JSON_STRING_INVALID returned for incomplete true, false, null
vikethehube opened this issue · 0 comments
vikethehube commented
Add these to incomplete_tests in unit_test.c: "{a:t", "{a:f", "{a:n",
and you get a test failure- the parser returns JSON_STRING_INVALID
when it should return JSON_STRING_INCOMPLETE
.
This is because the tests in parse_value
for true
, false
, and null
attempt to match the entire value only. They need to match a partial value as well, and if it is partial, return JSON_STRING_INCOMPLETE
.
May I suggest something like this (for each of null
, true
, and false
):
} else if (ch == 'n') {
TRY(test_and_skip(f, 'n'));
TRY(test_and_skip(f, 'u'));
TRY(test_and_skip(f, 'l'));
TRY(test_and_skip(f, 'l'));
TRY(capture_ptr(f, f->cur - 4, JSON_TYPE_NULL));
capture_len(f, f->num_tokens - 1, f->cur);
Which seems to work, but is a little bit ugly.