enhanced json error handling

This commit is contained in:
hyung-hwan 2021-07-14 13:46:15 +00:00
parent af9aad6aae
commit c42427d6ed

View File

@ -182,6 +182,11 @@ static int invoke_data_inst (mio_json_t* json, mio_json_inst_t inst)
if (inst != MIO_JSON_INST_STRING && inst != __INST_WORD_STRING)
{
if (inst == MIO_JSON_INST_END_ARRAY)
mio_seterrbfmt (json->mio, MIO_EINVAL, "object key not a string - <array>");
else if (inst == MIO_JSON_INST_END_OBJECT)
mio_seterrbfmt (json->mio, MIO_EINVAL, "object key not a string - <object>");
else
mio_seterrbfmt (json->mio, MIO_EINVAL, "object key not a string - %.*js", json->tok.len, json->tok.ptr);
return -1;
}