From df0c67264ec1c5d39377a25ff618715aa337a319 Mon Sep 17 00:00:00 2001 From: liekkas Date: Thu, 21 Jan 2016 16:10:26 +0800 Subject: [PATCH] add a space argument used to format the final string --- html/main.js | 2 +- jsonfn.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/html/main.js b/html/main.js index d3bba48..7985509 100644 --- a/html/main.js +++ b/html/main.js @@ -48,7 +48,7 @@ function testDate(){ } function showStringObj(){ - alert(JSONfn.stringify(jsonfnObj)); + alert(JSONfn.stringify(jsonfnObj, '\t')); } diff --git a/jsonfn.js b/jsonfn.js index 7f974c7..19f95f6 100644 --- a/jsonfn.js +++ b/jsonfn.js @@ -32,7 +32,7 @@ (function (exports) { - exports.stringify = function (obj) { + exports.stringify = function (obj, space) { return JSON.stringify(obj, function (key, value) { if (value instanceof Function || typeof value == 'function') { @@ -42,7 +42,7 @@ return '_PxEgEr_' + value; } return value; - }); + }, space); }; exports.parse = function (str, date2obj) {