separate error for invalid array members - json2tsv - JSON to TSV converter
 (HTM) git clone git://git.codemadness.org/json2tsv
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit f0b7f8935d41162e29c5a01f15273ba225909969
 (DIR) parent 0329ac9b10b3d47b509afca6f82078bf50b32480
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Tue, 15 Oct 2019 18:56:21 +0200
       
       separate error for invalid array members
       
       error: "member, but not in an object/array"
       
       example of such bad input:
       1,2,3
       
       Diffstat:
         M json2tsv.c                          |       8 ++++++--
       
       1 file changed, 6 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/json2tsv.c b/json2tsv.c
       @@ -252,8 +252,12 @@ parsejson(void (*cb)(struct json_node *, size_t, const char *), const char **err
                                        cb(nodes, depth + 1, value);
                                        v = 0;
                                }
       -                        if (!depth ||
       -                            (c == ']' && nodes[depth - 1].type != TYPE_ARRAY) ||
       +                        if (!depth) {
       +                                *errstr = JSON_ERROR_MEMBER;
       +                                goto end;
       +                        }
       +
       +                        if ((c == ']' && nodes[depth - 1].type != TYPE_ARRAY) ||
                                    (c == '}' && nodes[depth - 1].type != TYPE_OBJECT)) {
                                        *errstr = JSON_ERROR_BALANCE;
                                        goto end;