I’m working with an IHP controller that receives a JSON payload representing multiple records to process in a single request. Here’s a simplified example:
json
CopyEdit
{
"changes": [
{
"type": "person",
"method": "POST",
"data": {
"uuid": "f0ebe4b5-78af-5e27-b0cf-d103c5672a99",
"label": "123",
"health_center": "69f3ee80-6eab-4fe5-9e89-870692f14f64"
}
},
{
"type": "person",
"method": "PATCH",
"data": {
"uuid": "d810c62c-1f7c-570f-94ef-834bdfb8f1f3",
"label": "another new",
"health_center": "69f3ee80-6eab-4fe5-9e89-870692f14f64"
}
}
]
}
Each item in the changes
array contains a data
object with the record’s fields.
I’d like to loop over the array and, for each data
, treat it like form input so I can use IHP’s standard fill @'["...
function.
Or maybe there’s a better way? One that doesn’t force me to write an FromJSON
for each different records.