added MIO_JSON_OPTIONAL_COMMA
This commit is contained in:
parent
3e0654e131
commit
33afbfc419
@ -120,6 +120,7 @@ int main (int argc, char* argv[])
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (strcmp(argv[i], "--permit-word-key") == 0) o |= MIO_JSON_PERMIT_WORD_KEY;
|
||||
if (strcmp(argv[i], "--optional-comma") == 0) o |= MIO_JSON_OPTIONAL_COMMA;
|
||||
}
|
||||
|
||||
mio = mio_open(MIO_NULL, 0, MIO_NULL, 512, MIO_NULL);
|
||||
|
@ -503,8 +503,15 @@ static int handle_char_in_array (mio_json_t* json, mio_ooci_t c)
|
||||
{
|
||||
if (json->state_stack->u.ia.got_value)
|
||||
{
|
||||
mio_seterrbfmt (json->mio, MIO_EINVAL, "comma required in array - %jc", (mio_ooch_t)c);
|
||||
return -1;
|
||||
if (json->option & MIO_JSON_OPTIONAL_COMMA)
|
||||
{
|
||||
json->state_stack->u.ia.got_value = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
mio_seterrbfmt (json->mio, MIO_EINVAL, "comma required in array - %jc", (mio_ooch_t)c);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (c == '\"')
|
||||
@ -589,8 +596,14 @@ static int handle_char_in_object (mio_json_t* json, mio_ooci_t c)
|
||||
}
|
||||
else if (json->state_stack->u.io.state == 3)
|
||||
{
|
||||
mio_seterrbfmt (json->mio, MIO_EINVAL, "comma required in object - %jc", (mio_ooch_t)c);
|
||||
return -1;
|
||||
if (json->option & MIO_JSON_OPTIONAL_COMMA)
|
||||
{
|
||||
json->state_stack->u.io.state = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
mio_seterrbfmt (json->mio, MIO_EINVAL, "comma required in object - %jc", (mio_ooch_t)c);
|
||||
}
|
||||
}
|
||||
|
||||
if (c == '\"')
|
||||
|
Loading…
Reference in New Issue
Block a user