Browse Source

Merge remote-tracking branch 'upstream/master'

Rashid Khan 12 năm trước cách đây
mục cha
commit
1d015e9e04
1 tập tin đã thay đổi với 11 bổ sung1 xóa
  1. 11 1
      common/lib/shared.js

+ 11 - 1
common/lib/shared.js

@@ -271,7 +271,17 @@ function flatten_json(object,root,array) {
     var rootname = root.length == 0 ? index : root + '.' + index;
     if(typeof obj == 'object' ) {
       if(_.isArray(obj)) {
-        if(obj.length === 1 && _.isNumber(obj[0])) {
+        if(obj.length > 0 && typeof obj[0] === 'object') {
+          var strval = '';
+          for (var objidx = 0, objlen = obj.length; objidx < objlen; objidx++) {
+            if (objidx > 0) {
+              strval = strval + ', ';
+            }
+            
+            strval = strval + JSON.stringify(obj[objidx]);
+          }
+          array[rootname] = strval;
+        } else if(obj.length === 1 && _.isNumber(obj[0])) {
           array[rootname] = parseFloat(obj[0]);
         } else {
           array[rootname] = typeof obj === 'undefined' ? null : obj.join(',');