嗨,我想将json对象转换为具有特殊字符的字符串转义。将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包含一些额外的插件,因为它的字符串化功能无法正常工作。例如
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
ptype: 'cellediting'
})
]
这是事情没有为我工作的地方,我希望有人能帮助我在这里。
在此先感谢。
你尝试过什么? - > JSON.parse ??? - > https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/parse – GreenGuerilla 2013-03-06 14:04:23
这不是同一个问题。 OP要求转义某些字符。停止投票结束这个问题。 – 2013-03-06 14:06:44
另外'JSON.parse'是完全错误的,'stringify'是正确的。 – Christoph 2013-03-06 14:12:58