Diysb Tools

字符串化 JSON

将 JavaScript 对象转换为 JSON 字符串格式。将数据结构序列化为 JSON 字符串以便存储或传输。

JSON 工具
JavaScript 对象/数组输入
JSON 字符串输出
工具选项
缩进设置
使用空格
使用空格缩进输出
使用制表符
使用制表符缩进输出
选项
将HTML特殊字符转换为实体引用
字符串化 JSON 示例

Simple Object to JSON

Convert a basic JavaScript object into a JSON string.

{ name: "John", age: 30 }
{ name: "John", age: 30 }
{ "name": "John", "age": 30 }
{ "name": "John", "age": 30 }
缩进设置
使用空格
使用空格缩进输出
使用制表符
使用制表符缩进输出
选项
将HTML特殊字符转换为实体引用

Array with Mixed Types

Convert an array containing different types of values into JSON.

[1, "hello", true, null, { x: 10 }]
[1, "hello", true, null, { x: 10 }]
[ 1, "hello", true, null, { "x": 10 } ]
[ 1, "hello", true, null, { "x": 10 } ]
缩进设置
使用空格
使用空格缩进输出
使用制表符
使用制表符缩进输出
选项
将HTML特殊字符转换为实体引用

HTML-Escaped JSON

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: > & ' \"" }
{ &quot;html&quot;: &quot;&lt;div&gt;Hello &amp; Welcome&lt;/div&gt;&quot;, &quot;message&quot;: &quot;Special chars: &lt; &gt; &amp; &#039; &quot;&quot; }
{ &quot;html&quot;: &quot;&lt;div&gt;Hello &amp; Welcome&lt;/div&gt;&quot;, &quot;message&quot;: &quot;Special chars: &lt; &gt; &amp; &#039; &quot;&quot; }
缩进设置
使用空格
使用空格缩进输出
使用制表符
使用制表符缩进输出
选项
将HTML特殊字符转换为实体引用