我正在从json获取api响应,我如何将2字段值连接到字符串列表
{
"entity_id": "65",
"user_id": "37",
"tenancy_random_no_prefix": "C2",
"tenancy_random_no": "10001",
"unit_name": "1490",
"owner_name": "Emaar",
}
{
"entity_id": "66",
"user_id": "37",
"tenancy_random_no_prefix": "C2",
"tenancy_random_no": "10002",
"unit_name": "1490",
"owner_name": "arham",
}
如何获取列表= [owner_name + tenancy_random_no]这样会来
['Emaar10001','arham10002']
最佳答案
final source = [
{
"entity_id": "65",
"user_id": "37",
"tenancy_random_no_prefix": "C2",
"tenancy_random_no": "10001",
"unit_name": "1490",
"owner_name": "Emaar",
},
{
"entity_id": "66",
"user_id": "37",
"tenancy_random_no_prefix": "C2",
"tenancy_random_no": "10002",
"unit_name": "1490",
"owner_name": "arham",
}
];
var result = [];
for (var entity in source) {
result.add(['${entity['owner_name']} ${entity['tenancy_random_no']}']);
}
print(result);