Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for JSON to return null instead of empty array #709

Open
kitzberger opened this issue Feb 28, 2024 · 1 comment
Open

Option for JSON to return null instead of empty array #709

kitzberger opened this issue Feb 28, 2024 · 1 comment

Comments

@kitzberger
Copy link
Contributor

kitzberger commented Feb 28, 2024

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
  }
}
@twoldanski
Copy link
Collaborator

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants