fixed a bug in the json writer functions

This commit is contained in:
hyung-hwan 2021-07-21 07:36:10 +00:00
parent 6287eceddb
commit bb57c88d6e

View File

@ -1250,7 +1250,7 @@ int mio_jsonwr_write (mio_jsonwr_t* jsonwr, mio_json_inst_t inst, int is_uchars,
case MIO_JSON_INST_START_ARRAY: case MIO_JSON_INST_START_ARRAY:
if (sn->state != MIO_JSON_STATE_START && sn->state != MIO_JSON_STATE_IN_ARRAY && if (sn->state != MIO_JSON_STATE_START && sn->state != MIO_JSON_STATE_IN_ARRAY &&
!(sn->state == MIO_JSON_STATE_IN_OBJECT && sn->obj_awaiting_val)) goto incompatible_inst; !(sn->state == MIO_JSON_STATE_IN_OBJECT && sn->obj_awaiting_val)) goto incompatible_inst;
if (sn->index > 0) WRITE_COMMA (jsonwr); if (sn->index > 0 && sn->state == MIO_JSON_STATE_IN_ARRAY) WRITE_COMMA (jsonwr);
sn->index++; sn->index++;
if ((jsonwr->flags & MIO_JSONWR_FLAG_PRETTY) && if ((jsonwr->flags & MIO_JSONWR_FLAG_PRETTY) &&
!(sn->state == MIO_JSON_STATE_IN_OBJECT && sn->obj_awaiting_val)) !(sn->state == MIO_JSON_STATE_IN_OBJECT && sn->obj_awaiting_val))
@ -1267,7 +1267,7 @@ int mio_jsonwr_write (mio_jsonwr_t* jsonwr, mio_json_inst_t inst, int is_uchars,
case MIO_JSON_INST_START_OBJECT: case MIO_JSON_INST_START_OBJECT:
if (sn->state != MIO_JSON_STATE_START && sn->state != MIO_JSON_STATE_IN_ARRAY && if (sn->state != MIO_JSON_STATE_START && sn->state != MIO_JSON_STATE_IN_ARRAY &&
!(sn->state == MIO_JSON_STATE_IN_OBJECT && sn->obj_awaiting_val)) goto incompatible_inst; !(sn->state == MIO_JSON_STATE_IN_OBJECT && sn->obj_awaiting_val)) goto incompatible_inst;
if (sn->index > 0) WRITE_COMMA (jsonwr); if (sn->index > 0 && sn->state == MIO_JSON_STATE_IN_ARRAY) WRITE_COMMA (jsonwr);
sn->index++; sn->index++;
if ((jsonwr->flags & MIO_JSONWR_FLAG_PRETTY) && if ((jsonwr->flags & MIO_JSONWR_FLAG_PRETTY) &&
!(sn->state == MIO_JSON_STATE_IN_OBJECT && sn->obj_awaiting_val)) !(sn->state == MIO_JSON_STATE_IN_OBJECT && sn->obj_awaiting_val))