fix of array exporting in json export mode
authoradam <adamansky@gmail.com>
Fri, 19 Jul 2013 04:18:41 +0000 (11:18 +0700)
committeradam <adamansky@gmail.com>
Fri, 19 Jul 2013 04:18:41 +0000 (11:18 +0700)
package.json
tcejdb/bson.c

index 453060a..f977639 100644 (file)
@@ -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"
index e873bff..00a86f8 100644 (file)
@@ -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: