我有一个名为data的嵌套javascript对象。有没有什么方法可以遍历它并找到所有具有未定义值的属性,并将其设置为字符串“undefined”insted。如果在IE7中属性值未定义,JSON不会验证。由于找到并更改undefined值的属性
{
"Target": "System",
"Systemoperation": "Buy-In",
"Systemorigin": "ABB",
"Subscriptionmode": "Maintain & Evolve",
"Evolveto": "800xA",
"Quoteselection": "Full Quote",
"Commitmenttimeframe": "3 years",
"codevalues": {
"Target": 100,
"Systemoperation": 110,
"Systemorigin": false,
"Subscriptionmode": 4,
"Evolveto": undefined,
"Quoteselection": "fullquote",
"Commitmenttimeframe": 3
},
"Route": [
"System",
"Buy-In",
"ABB",
"Maintain & Evolve",
"800xA",
"Full Quote",
"3 years"
],
"currentsystem": ""
}
这里是evolteto在codevalues不确定。哪些不验证(尝试http://jsonlint.com/)。
任何代码到目前为止打电话了吗? – Niels
请为我们创建一个示例来看看:http://jsfiddle.net/ – Rumplin
@Niels更新后 – Johan