在html中怎么格式化json字符串

方法一、
参考:
https://blog.csdn.net/zhengxiangwen/article/details/68927330
这里主要用到了JSON.stringify(songResJson,null,2)方法,

其中songResJson是在js中声明的json对象,2表示缩进两个空格。

其详细用法可查看:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify

还可以添加样式,参见:http://www.jianshu.com/p/04127d74d88c

方法二、
使用了angular框架,里面管道是有json格式化的

猜你喜欢

转载自blog.csdn.net/weixin_42995876/article/details/85235547