我的json采用以下格式
[{
"Id": "ALFKI",
"Contact Name": "Maria Anders",
"Contact Title": "Sales Representative",
"City": "Berlin",
"Slider": 10
}, {
"Id": "ANATR",
"Contact Name": "Ana Trujillo",
"Contact Title": "Owner",
"City": "México D.F.",
"Slider": 5
}]
我想要的Json
[{
"Id": "ALFKI",
"ContactName": "Maria Anders",
"ContactTitle": "Sales Representative",
"City": "Berlin",
"Slider": 10
}, {
"Id": "ANATR",
"ContactName": "Ana Trujillo",
"ContactTitle": "Owner",
"City": "México D.F.",
"Slider": 5
}]
Kendo网格不接受带空格的键名
答案 0 :(得分:6)
您可以使用JSON.stringify()
,JSON.parse()
,String.prototype.replace()
与RegExp
/\s(?=\w+":)/g
匹配空格字符,后跟一个或多个单词字符,后跟{{1 }后跟"
: