我在从对象数组创建对象时遇到了for循环中的一些问题。我在node js应用程序中有一个对象:
我正在为rest api工作,必须得到正确的响应。
[
{
"issuer_id": 2639,
"job_title": "Sales Manager",
"hr-contact": "9767865459",
"adress": "bangalore",
"image": "http://localhost:3003/public/uploads/company-logos/undefined",
"getEmployerDetail": [
{
"issuer_id": 2639,
"Field_of_activity": "Jobs",
"id": 111,
"Section": "Communes",
"Content": "Mühlwald",
"foa_section_content_id": 111
},
{
"issuer_id": 2639,
"Field_of_activity": "Jobs",
"id": 112,
"Section": "Communes",
"Content": "Wolkenstein in Gröden",
"foa_section_content_id": 112
},
{
"issuer_id": 2639,
"Field_of_activity": "Jobs",
"id": 113,
"Section": "Communes",
"Content": "Schnals",
"foa_section_content_id": 113
},
{
"issuer_id": 2639,
"Field_of_activity": "Jobs",
"id": 150,
"Section": "Professional field",
"Content": "Marketing, Graphics, PR",
"foa_section_content_id": 150
},
{
"issuer_id": 2639,
"Field_of_activity": "Jobs",
"id": 162,
"Section": "Branch",
"Content": "Banks, Finance, Insurance",
"foa_section_content_id": 162
},
{
"issuer_id": 2639,
"Field_of_activity": "Jobs",
"id": 215,
"Section": "Benefits",
"Content": "Enrolment programme",
"foa_section_content_id": 215
},
{
"issuer_id": 2639,
"Field_of_activity": "Jobs",
"id": 220,
"Section": "Benefits",
"Content": "Childcare",
"foa_section_content_id": 220
}
]
}
]
我想返回这样的对象,其中包含所有的材料作为数组,名称和对象数组中的值如下:
我想用for循环得到结果。
[
{
"issuer_id": 2639,
"job_title": "Sales Manager",
"hr-contact": "9767865459",
"adress": "bangalore",
"image": "http://localhost:3003/public/uploads/company-logos/undefined",
"employmentType": [
{
"id": 198,
"Employment_type": "Freelancer"
}
],
"professionalField": [
{
"id": 150,
"Professional_field": "Marketing, Graphics, PR"
}
],
"benefits": [
{
"id": 215,
"Benefits": "Enrolment programme"
},
{
"id": 219,
"Benefits": "Canteen"
},
{
"id": 220,
"Benefits": "Childcare"
},
{
"id": 221,
"Benefits": "Employee events"
},
{
"id": 222,
"Benefits": "Employee mobile phone"
},
{
"id": 223,
"Benefits": "Employee notebook"
},
{
"id": 224,
"Benefits": "Employee bonuses"
}
],
"branch": [
{
"id": 162,
"Branch": "Banks, Finance, Insurance"
}
],
"communes": [],
"positionLevel": [],
"skillSets": [],
"languageSkills": [],
"skillRepository": [],
"jobCluster": [],
"jobClusterDescription": []
}
]
2条答案
按热度按时间jmo0nnb31#
kg7wmglp2#
这个第一个查询,我们得到了一些数据,我们使用ID附加数据,上面你发送了这个API的逻辑,你能写我在下面的foreach逻辑中使用的逻辑吗?我需要你用那个逻辑写的响应。