Show JSON data in a beautiful indentation format, and use the simplest json.stringify function, because this function also has the latter two parameters that are not commonly used.
See mdn https://developer.mozilla.org/zh-docs/web/javascript/reference/global_objects/json/stringify.
The example code is as follows:
html; "> <html> <head> <meta charset = UTF-8 /> <Title> Hello < /Title> <Style> Pre {outline: 1px solid #ccc; padding: 5px; 5px;} .string {color: green;} .number {color: darkorange;} .Boolean {color: blue;}. Null {color: magenta;} .Key {color: red;} </style> <script type = text// javascript> Function SyntaxHighlight (json) {if (typeof json! = 'String') {json = json.stringify (json, undefined, 2);} json = json.replace (/&/g, '&'). replace (// </g, '<<'). Replace (/>/g, '>'); Return json.replace (/(//(/u [a-za-z0-9] {4} | // [^u ] | [^//])*(/s*:)? |/b (true | false | null)/b |-?/d+(?: /./ d*)? (?: [ee] [ +/-]?/d+)?)/G, Function (MATCH) {Var CLS = 'Number'; if (/^/.test (match)) {if (/: $/.test (match)) { CLS = 'Key';} Else {class = 'String';}} Else if (/True| False/.test (match)) {cls = 'boolean'; ) {cls = 'null';} Return '<span class =' + class + '>' + match + '</span>';}); =result> </pre> <script type=text/javascript> var songResJson={ service: ALL, qt: 581, content: { answer: { song: 如果缘只到遇见, album: 如果缘只到遇见, artist : Wu Qilong Yan Yidan, pic_url: http://p1.music.126.net/- u3wgixsfncw7d8jy7pcea==/5921969627395387.jpg}, Scene: Music}} 'Result'). InnerHtml = SyntaxHighlight (songresjson) ; // $ ('#Result'). HTML (Syntaxhighlight (Songresjson)); </Script> </Body> </html>The above is all the contents of this article. I hope it will be helpful to everyone's learning. I also hope that everyone will support VEVB Wulin.com.