JSON Arrays Not Consistent
Posted: February 24th, 2022, 9:45 am
I'm working on making REST APIs, but I'm having a little difficulty making the response consistent.
This is how the response returns normally.
When only a single employee is returned though, it's no longer in an array.
Is there any way to force it be an array like this?
This is how the response returns normally.
Code: Select all
{
"Response": {
"Employees": {
"Employee": [
{
"ContractorFormID": "1114",
"ContractorAddressBookNum": ""
},
{
"ContractorFormID": "1116",
"ContractorAddressBookNum": ""
}
]
}
}
}
When only a single employee is returned though, it's no longer in an array.
Code: Select all
{
"Response": {
"Employees": {
"Employee": {
"ContractorFormID": "1114",
"ContractorAddressBookNum": ""
}
}
}
}
Is there any way to force it be an array like this?
Code: Select all
{
"Response": {
"Employees": {
"Employee": [
{
"ContractorFormID": "1114",
"ContractorAddressBookNum": ""
}
]
}
}
}