由网友(正宗傻白甜)分享简介:我的目标是获得一个JSON数组像这样的:变参= {[名称:'测试',值:1},{关键:测试2,值:2}]。我怎样才能获得低于code建立像上述之一的阵列?this.dependentProperties = []; //数组功能addDependentProperty(depName,depValue){depend...
我的目标是获得一个JSON数组像这样的:
变参= {[名称:'测试',值:1},{关键:测试2,值:2}]。
我怎样才能获得低于code建立像上述之一的阵列?
this.dependentProperties = []; //数组
功能addDependentProperty(depName,depValue){
dependentProperties.push(新阵列(depName,depValue));
}
通过使用push方法我最终不得不像这样的一个JSON对象:
的args:{[[测试1,1],[测试2,2]}
解决方案
dependentProperties.push({名depName,值:depValue});
My aim is to get a json array like this one:
var args = [{ name: 'test', value: 1 }, { key: 'test2', value: 2}];
How can I get the below code to build up an array like the above one?
this.dependentProperties = []; //array
function addDependentProperty(depName, depValue) {
dependentProperties.push(new Array(depName, depValue));
}
By using the push method I end up having a json notation like this one:
args:{[["test1",1],["test2",2]]}
解决方案
dependentProperties.push({name: depName, value: depValue});
相关推荐
最新文章