У меня проблема, я хочу преобразовать несколько parentId JSON в single parentId JSON вот пример нескольких родительских json, которые я предоставлю своей функции js.
[{
"id": "1",
"name": "first_name",
"label": "First Name",
"placeholder": "Enter Your First Name",
"required": "yes",
"inputType": "text",
"options": [],
"parentId": "",
"isPost": true
},
{
"id": "4",
"name": "ready_to_provide_email_address",
"label": "Ready to Provide Email Address",
"placeholder": "Enter Your Phone Number",
"required": "yes",
"inputType": "radio",
"options": [{
"label": "Yes",
"name": "ready_to_provide_email",
"value": "Yes",
"id": "5"
},
{
"label": "No",
"name": "ready_to_provide_email",
"value": "No",
"id": "6"
}
],
"parentId": "",
"isPost": false
},
{
"id": "7",
"name": "email",
"label": "Email",
"placeholder": "Enter Your Email",
"required": "yes",
"inputType": "text",
"options": [],
"parentId": ["5", "6"],
"isPost": true
}
]
И это единственный родительский json, который я хочу выводить.
[{
"id": "1",
"name": "first_name",
"label": "First Name",
"placeholder": "Enter Your First Name",
"required": "yes",
"inputType": "text",
"options": [],
"parentId": "",
"isPost": true
},
{
"id": "4",
"name": "ready_to_provide_email_address",
"label": "Ready to Provide Email Address",
"placeholder": "Enter Your Phone Number",
"required": "yes",
"inputType": "radio",
"options": [{
"label": "Yes",
"name": "ready_to_provide_email",
"value": "Yes",
"id": "5"
},
{
"label": "No",
"name": "ready_to_provide_email",
"value": "No",
"id": "6"
}
],
"parentId": "",
"isPost": false
}, {
"id": "7",
"name": "email",
"label": "Email",
"placeholder": "Enter Your Email",
"required": "yes",
"inputType": "text",
"options": [],
"parentId": "5",
"isPost": true
},
{
"id": "8",
"name": "email",
"label": "Email",
"placeholder": "Enter Your Email",
"required": "yes",
"inputType": "text",
"options": [],
"parentId": "6",
"isPost": true
}
]
Примечание: object.option.id - это родительский идентификатор элемента в моем случае. Пожалуйста, помогите мне. Заранее большое спасибо.