zoukankan      html  css  js  c++  java
  • JSON对象转字符串


     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         }
  • 相关阅读:
    log日志----logging模块
    配置文件--configparser
    面向对象——进阶
    面向对象
    内置函数
    模块和包
    常用模块
    正则表达式
    递归函数
    内置函数+匿名函数
  • 原文地址:https://www.cnblogs.com/Pynix/p/1452290.html
Copyright © 2011-2022 走看看