你好,我想将JSON对象转换为带有特殊字符转义的字符串。
以下是示例:
{
"xtype": "window",
"height": 250,
"width": 400,
"bodyPadding": "20 0 0 20",
"title": "Configuration",
"modal": true,
"items": [
{
"xtype": "textfield",
"fieldLabel": "Deploy Path"
},
{
"xtype": "textfield",
"fieldLabel": "Save Path"
},
{
"xtype": "button",
"margin": "20 0 0 100",
"text": "Save"
}
]
}
以上对象到
{\n \"xtype\": \"window\",\n \"height\": 250,\n \"width\": 400,\n \"bodyPadding\": \"20 0 0 20\",\n \"title\": \"Configuration\",\n \"modal\": true,\n \"items\": [\n {\n \"xtype\": \"textfield\",\n \"fieldLabel\": \"Deploy Path\"\n },\n {\n \"xtype\": \"textfield\",\n \"fieldLabel\": \"Save Path\"\n },\n {\n \"xtype\": \"button\",\n \"margin\": \"20 0 0 100\",\n \"text\": \"Save\"\n }\n ]\n}
请问有人可以帮我吗?
先行谢过。
你好,
我的JSON包含一些附加插件,导致stringify函数无法正常工作。例如:
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
ptype: 'cellediting'
})
]
这里有些问题让我无法正常工作,希望有人能够在这里帮助我解决。
提前感谢您的帮助。
JSON.parse
是完全错误的,正确的应该是stringify
。 - Christoph