Home >Web Front-end >JS Tutorial >JSON formatted output_jquery

JSON formatted output_jquery

WBOY
WBOYOriginal
2016-05-16 16:31:432606browse

Today there is a requirement to format the output JSON

The first thing that comes to mind is a small plug-in such as jsBeautifier

After searching for a while, I saw a friend answered that JSON.stringify can output formatted JSON strings

Copy code The code is as follows:

JSON.stringify(jsObj, null, "t"); // Indent one tab
JSON.stringify(jsObj, null, 4); // Indent 4 spaces

Hmm, not bad

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn