我有一个返回表单对象的函数:
[{"key":"name","value":"ali","key":"age","value":"56"}]
当调用时,如下所示。我怎样才能让它返回相同类型的对象但没有方括号?
setProperties('{"name":"ali","age":"56"}');
function setProperties(str) {
var properties = [];
var json = jQuery.parseJSON(str);
for (property in json) {
properties.push({
key: property,
value: json[property]});
}
return properties;
}