From bb57c88d6e6bbb8a989b8ca0117c2e675f2289fd Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 21 Jul 2021 07:36:10 +0000 Subject: [PATCH] fixed a bug in the json writer functions --- mio/lib/json.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mio/lib/json.c b/mio/lib/json.c index 63c2567..6b7abfc 100644 --- a/mio/lib/json.c +++ b/mio/lib/json.c @@ -1250,12 +1250,12 @@ int mio_jsonwr_write (mio_jsonwr_t* jsonwr, mio_json_inst_t inst, int is_uchars, case MIO_JSON_INST_START_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; - if (sn->index > 0) WRITE_COMMA (jsonwr); + if (sn->index > 0 && sn->state == MIO_JSON_STATE_IN_ARRAY) WRITE_COMMA (jsonwr); sn->index++; if ((jsonwr->flags & MIO_JSONWR_FLAG_PRETTY) && !(sn->state == MIO_JSON_STATE_IN_OBJECT && sn->obj_awaiting_val)) { - WRITE_INDENT (jsonwr); + WRITE_INDENT (jsonwr); } sn->obj_awaiting_val = 0; WRITE_BYTES_NOESC (jsonwr, "[", 1); @@ -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: 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; - if (sn->index > 0) WRITE_COMMA (jsonwr); + if (sn->index > 0 && sn->state == MIO_JSON_STATE_IN_ARRAY) WRITE_COMMA (jsonwr); sn->index++; if ((jsonwr->flags & MIO_JSONWR_FLAG_PRETTY) && !(sn->state == MIO_JSON_STATE_IN_OBJECT && sn->obj_awaiting_val))