JSON 데이터를 아름다운 들여 쓰기 형식으로 표시하고 가장 간단한 json.stringify 함수를 사용하십시오.이 기능에는 일반적으로 사용되지 않는 두 가지 매개 변수도 있습니다.
mdn https://developer.mozilla.org/zh-docs/web/javaScript/reference/global_objects/json/stringify를 참조하십시오.
예제 코드는 다음과 같습니다.
html; "> <html> <head> <meta charset = utf-8 /> <title> hello < /title> <style> pre {개요 : 1px solid #ccc; 패딩 : 5px; 5px;} .String {color. : green;} .number {color : darkorange;} .Boolean {color : blue;}. SyntaxHighlight (json) {if (typeof json! = 'string') {json = json.stringify (json, undefined, 2);} json = json.replace (/&/g, '&'. </g, '<<'). ^u] |. [^//])*(/s*:)? ] [+/-]?/d +)/g, function (match) {var cls = 'number'; ) {cls = 'key';} else {class = 'string';}} if (/true | false/.test (match)) {cls = 'boolean') {cls = 'null'; } return '<span class =' + class + '>' + match + '</span>';}); All, Qt : 581, 내용 : {Answer : {song : 如果缘只到遇见 : 앨범 : 如果缘只到遇见 : wu Qilong Yan Yidan, pic_url : http://p1.music.126.net/-- U3wgixsfncw7d8jy7pcea ==/5921969627395387.jpg}. 바디> </html>위는이 기사의 모든 내용입니다.