W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h1>使用 <em>reviver</em> 函数</h1> <p>大写 “city” 的值:</p> <p id="demo"></p> <script> var text = '{ "name":"Bill", "age":"19", "city":"Seattle"}'; var obj = JSON.parse(text, function (key, value) { if (key == "city") { return value.toUpperCase(); } else { return value; } }); document.getElementById("demo").innerHTML = obj.name + ", " + obj.city; </script> </body> </html>