JSONデータを美しいインデント形式で表示し、最も単純なJSON.Stringify関数を使用します。この関数には、後者の2つのパラメーターも一般的に使用されていないためです。
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 {outline:1px solid #ccc; padding:5px;} .string {color :green;} .number {color:darkorange;} .boolean {color:blue;}。 syntaxhighlight(json){if(typeof json!= 'string'){json = json.stringify(json、undefined、2);} json.replace(/&/g、& ')。 </g、 '<<') ^u] | ] [+/-]?/d +)/g、function(mate){var cls = 'number'; ){cls = 'key';} else {class = 'string';}} if(/true | false/.test(mate)){cls = 'null'; } return '<span class =' + class + '>' + '</span>';}); All、Qt:581、content:{Answer:{song:如果缘只到遇见、アルバム:如果缘只到遇见、アーティスト:Wu Qilong Yan Yidan、pic_url:http://p1.music.126.net/-- u3wgixsfncw7d8jy7pcea ==/5921969627395387.jpg}}} 'result')ボディ> </html>上記は、この記事のすべての内容です。