将 JavaScript 对象转换为 JSON 字符串格式。将数据结构序列化为 JSON 字符串以便存储或传输。
Convert a basic JavaScript object into a JSON string.
{ name: "John", age: 30 }{
"name": "John",
"age": 30
}Convert an array containing different types of values into JSON.
[1, "hello", true, null, { x: 10 }][
1,
"hello",
true,
null,
{
"x": 10
}
]Convert an object to JSON with HTML characters escaped.
{
html: "<div>Hello & Welcome</div>",
message: "Special chars: > & ' \""
}{
"html": "<div>Hello & Welcome</div>",
"message": "Special chars: < > & ' ""
}