headless
headless copied to clipboard
Option for JSON to return null instead of empty array
In 2.x and (behind a compatibility feature flag) in 3.x it was possible to let the JsonContentObject (JSON) return null instead of an empty array.
I'd like to propose a new flag ifEmptyReturnNull for that JSON cObject. A flag with that name is already present for rendering the fields, which is cool and should be kept that way!
lib.test = JSON
lib.test.fields {
propertyOne = TEXT
propertyOne.value =
propertyOne.ifEmptyReturnNull = 1
}
Here's an example to back my proposal: JSON's always rendering an empty array instead of the IMHO more correct null in case no record can be fetched:
lib.test = JSON
lib.test {
dataProcessing.10 = FriendsOfTYPO3\Headless\DataProcessing\DatabaseQueryProcessor
dataProcessing.10 {
table = ....
fields {
propertyOne = TEXT
propertyOne.field = header
propertyOne.ifEmptyReturnNull = 1
}
returnFlattenObject = 1
# That's the new flag!
ifEmptyReturnNull = 1
}
}
@kitzberger in 4.x by default dataProcessing is returning null instead of array, no flag needed, flag was meant for already built apps only so they won't break