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

PatternJsonProvider: provide a "#asNullIfEmpty{}" operation #773

Closed
brenuart opened this issue Mar 9, 2022 · 0 comments · Fixed by #774
Closed

PatternJsonProvider: provide a "#asNullIfEmpty{}" operation #773

brenuart opened this issue Mar 9, 2022 · 0 comments · Fixed by #774
Milestone

Comments

@brenuart
Copy link
Collaborator

brenuart commented Mar 9, 2022

It would be very handy to have a #asNullIfEmpty{...} operation to convert an empty string into a null value.

People may want to use it together with the #property{} conversion specifier to return null instead of an empty string when the property is not defined. For instance, assuming the "foo" property is not defined, the following configuration:

<pattern>
   { "foo": "#asNullIfEmpty{%property{foo}}" }
</pattern>

... would produce a result like this:

{
   "foo": null
}
@brenuart brenuart added this to the 7.1 milestone Mar 9, 2022
@brenuart brenuart changed the title PatternJsonProvider: provide a "#nullIfEmpty{}" operation PatternJsonProvider: provide a "#asNullIfEmpty{}" operation Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant