我对开发非常陌生,我正在尝试找出转换当前导出工具的最佳方法,我编写的导出JSON对象现在包含一个内部有一个对象数组的JSON对象。我所指的是配置文件中的对象数组:我尝试使用.push()将对象放入数组中,但我迷失了。
理想的JSON对象
{
"id": "220a5f58-480e-45c3-8252-b3712d9e6c32",
"name": "hello",
"profile": [
{
"fullName": "test",
"displayName": "test",
"number": "Unknown",
"attributes": {
"identifier": true,
"categorical": false,
"quantized": false,
"relational": false,
"ordinal": false
}
},
{
"fullName": "test",
"displayName": "test",
"number": "Unknown",
"attributes": {
"identifier": true,
"categorical": false,
"quantized": false,
"relational": false,
"ordinal": false
}
}
],
"test": 12
}
JS代码
// object.profile is a JSON object
export.profile = [];
angular.forEach(object.profile, function (value, key) {
//export.profile[key] = {};
export.push(profile[key] );
export.profile[key].attributes = {};
export.profile[key].fullName = (value['original-name']);
export.profile[key].displayName = (value['display-name']);
export.profile[key].interpretation = (value['interpretation']['iName']);
export.profile[key].mainType = (value['main-type']);