-
Notifications
You must be signed in to change notification settings - Fork 119
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
Configure jslt to include keys for null or {} values instead of omitting the key #51
Comments
This is something I was thinking we'd have to make configurable at some point. How do you want to configure it? Would a JSLT expression as filter work? |
Would it have the flexibility of having control over each key (to include or not if null). Or would it be a filter that applies to all keys i.e. include all null keys or exclude all null keys. |
I would say a filter to apply to all keys. If you want to control which key is included or not included you can handle that in the transform itself. |
let's say it's a filter to apply to all keys. Yet for a use case might be needed to have control per key rather than globally. Example:
There should be a means to achieve following results when needed. The global config doesn't cover case 1. 1
2
3
|
But you already have full control per key in the template. I don't think giving you that control in the filter actually helps you any. It just moves the challenge somewhere else, and complicates the system. I think I made my mind up:
|
Technically you are right. But what you have mentioned is also a great enhancement comparing to have no configuration option. |
It's true that you can't necessarily change other people's templates, but you can use them as input to your own template. At which point we're back where we started: making the template do what you want is just as easy as doing it in the filter. I'll make the change. This may require a deeper change in the JSLT API, due to poor initial design. But I'll solve that. |
That commit implements the filters, fixing this issue. @Mohammadcore Would be great if you could test this out. |
Currently keys with null or {} or [] value are omitted. Is there a way to configure this behavior or where in code can I patch this so I force it to include empty/null keys as well.
The text was updated successfully, but these errors were encountered: