美文网首页
js中json项对象转字符串

js中json项对象转字符串

作者: 俞宝山 | 来源:发表于2020-08-23 01:28 被阅读0次

    原始json:
       consot  values = {"id":"1294943322932195329","variables":{"name":"俞宝山","deptName":"科技部","time":["2020-07-22","2020-09-03"],"type":"4","remark":"备注"}}

    转换方式:

    for (let key in values) {

        if(typeof(values[key]) ==='object' ){

            values[key] = JSON.stringify(values[key])

        }

    }

    转换后:

    {"id":"1294943322932195329","variables":{"name":"俞宝山","deptName":"科技部","time":"[\"2020-07-22\",\"2020-09-03\"]","type":"4","remark":"备注"}}

    相关文章

      网友评论

          本文标题:js中json项对象转字符串

          本文链接:https://www.haomeiwen.com/subject/mxzbjktx.html