如何在我的页面上以漂亮的格式显示JSON对象?(复制)

时间:2021-03-27 11:17:38

Possible Duplicate:
JavaScript data formatting/pretty printer

可能的复制:JavaScript数据格式化/漂亮的打印机。

var theobject_string = '{...}'; // I have a json object as a string.

How can I display this string in a pretty way, on my webpage (html)?

我如何在我的网页(html)上以一种漂亮的方式显示这个字符串?

I want this the elements to be indented.

我希望元素缩进。

1 个解决方案

#1


1  

This library does exactly what you're looking for: http://www.cerny-online.com/cerny.js/demos/json-pretty-printing

这个库所做的正是您正在寻找的:http://www.cerny-online.com/cerny.js/demos/json-pretty打印

#1


1  

This library does exactly what you're looking for: http://www.cerny-online.com/cerny.js/demos/json-pretty-printing

这个库所做的正是您正在寻找的:http://www.cerny-online.com/cerny.js/demos/json-pretty打印