From f549aa02a8de61c501d62653381e31e2e4752454 Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 19 Jul 2013 11:18:41 +0700 Subject: [PATCH] fix of array exporting in json export mode --- package.json | 2 +- tcejdb/bson.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 453060a..f977639 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name" : "ejdb", - "version" : "1.1.14-3", + "version" : "1.1.14-4", "config" : { "windownloadurl_ia32" : "http://dl.dropboxusercontent.com/u/4709222/ejdb/tcejdb-1.1.14-mingw32-i686.zip", "windownloadurl_x64" : "http://dl.dropboxusercontent.com/u/4709222/ejdb/tcejdb-1.1.14-mingw32-x86_64.zip" diff --git a/tcejdb/bson.c b/tcejdb/bson.c index e873bff..00a86f8 100644 --- a/tcejdb/bson.c +++ b/tcejdb/bson.c @@ -2052,13 +2052,20 @@ static int _bson2json(_BSON2JSONCTX *ctx, bson_iterator *it, bool array) { int c = 0; while ((bt = bson_iterator_next(it)) != BSON_EOO) { if (c++ > 0) { + if (array) { + tcxstrcat2(out, "\n"); + BSPAD(0); + } tcxstrcat2(out, ",\n"); } const char *key = bson_iterator_key(it); BSPAD(0); - tcxstrcat2(out, "\""); - _jsonxstrescaped(out, key); - tcxstrcat2(out, "\" : "); + if (!array) { + tcxstrcat2(out, "\""); + _jsonxstrescaped(out, key); + tcxstrcat2(out, "\" : "); + } + switch (bt) { case BSON_LONG: case BSON_INT: -- 2.7.4