答案 0 :(得分:1)
您需要一个PRE标记来保留好的缩进(或将CSS white-space:pre
添加到目标标记中),然后使用JSON.stringify的第三个参数来添加缩进
var data = '[{"match_id":3469695808,"player_slot":3,"radiant_win":true,"duration":1237,"game_mode":22,"lobby_type":7,"hero_id":13,"start_time":1506540251,"version":20,"kills":11,"deaths":2,"assists":12,"skill":3,"leaver_status":0,"party_size":1}]'
document.getElementById('demo').innerHTML = JSON.stringify(JSON.parse(data),null, 4);

<pre id="demo"></pre>
&#13;