mm_expand 2.4.4 → 2.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/base.js +1 -1
- package/lib/object.js +3 -2
- package/package.json +1 -1
package/lib/base.js
CHANGED
|
@@ -861,7 +861,7 @@ Base.prototype._helpFormatResult = function (target) {
|
|
|
861
861
|
}
|
|
862
862
|
} else if (Array.isArray(target)) {
|
|
863
863
|
try {
|
|
864
|
-
return JSON.stringify(target);
|
|
864
|
+
return JSON.stringify(target, null, 2);
|
|
865
865
|
} catch (error) {
|
|
866
866
|
this.log('error', '序列化数组失败', error);
|
|
867
867
|
return '[Array]';
|
package/lib/object.js
CHANGED
|
@@ -337,11 +337,12 @@ function isEmptyValue(value, zero = false) {
|
|
|
337
337
|
* 转为json字符串
|
|
338
338
|
* @param {object} source 被转换的对象
|
|
339
339
|
* @param {boolean} format 是否格式化
|
|
340
|
+
* @param {number} space 缩进宽度,默认2个空格
|
|
340
341
|
* @returns {string} json格式字符串
|
|
341
342
|
*/
|
|
342
|
-
function toJson(source, format) {
|
|
343
|
+
function toJson(source, format, space = 2) {
|
|
343
344
|
if (format) {
|
|
344
|
-
return JSON.stringify(source, null,
|
|
345
|
+
return JSON.stringify(source, null, space);
|
|
345
346
|
} else {
|
|
346
347
|
return JSON.stringify(source);
|
|
347
348
|
}
|