1        /**
 2         * json对象转字符串形式
 3         */
 4         function json2str(o) {
 5             var arr = [];
 6             var fmt = function(s) {
 7                 if (typeof s == 'object' && s != nullreturn json2str(s);
 8                 return /^(string|number)$/.test(typeof s) ? "'" + s + "'" : s;
 9             }
10             for (var i in o) arr.push("'" + i + "':" + fmt(o[i]));
11             return '{' + arr.join(','+ '}';
12         }

相关文章:

  • 2021-11-21
  • 2021-06-04
  • 2022-02-07
  • 2022-12-23
  • 2022-02-07
  • 2021-12-27
  • 2021-12-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-02-21
  • 2022-01-18
  • 2022-02-07
相关资源
相似解决方案