标准JSON中值转换双引号

提交到服务器的的json中的某个字段是json字符串
  • 需要提交的json 字符串
var aa = {"id":35,"method":"call.setAdviseMedia","params":{"nid":"83605254241","medias":[{"operator":5,"streams":[{"modeIndex":1,"key":"layout_1","type":"main","attachment":{"rect":[0,0.25,0,0.5,0.5],"nid":"1307625745"}}]}]}}
  • 最终格式
{"mixWindowModel":"{\"id\":35,\"method\":\"call.setAdviseMedia\",\"params\":{\"nid\":\"83605254241\",\"medias\":[{\"operator\":5,\"streams\":[{\"modeIndex\":1,\"key\":\"layout_1\",\"type\":\"main\",\"attachment\":{\"rect\":[0,0.25,0,0.5,0.5],\"nid\":\"1307625745\"}}]}]}}"}
转换方式
console.log(JSON.stringify({"mixWindowModel":json_stringify(a)}))
posted @ 2022-05-18 17:19  vx_guanchaoguo0  阅读(132)  评论(0编辑  收藏  举报