More concise syntax for "Output a Field when Present" #64
Shadow-Devil
started this conversation in
Ideas
Replies: 1 comment 6 replies
-
This would also help reduce clutter when we have more than a few "optional" fields: Currently we have:
Would be easier to read/write this though:
|
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi I have an idea for a new language syntax: I found a common pattern in our code base:
which can become quite long e.g.
I know that there is the writer property skipNullOn='objects' but this treats every entry the same, so no fine-grained control is possible what should be skipped and what not.
My idea would be to add the following syntax, which is a shortcut to the above syntax:
If you need a key with a question mark at the end, it already has to be wrapped into a string, so the question mark could be after the string like this:
"key?"? : payload.value
.I think this is quite intuitive, since in RAML and for dataweave types this syntax specifies an optional key.
What do you think about this feature? 🙂
Idea was originally posted on slack: https://dataweavelanguage.slack.com/archives/C044FKW9XUK/p1670859340600209?thread_ts=1670859340.600209&cid=C044FKW9XUK
and https://dataweavelanguage.slack.com/archives/C03ULMDEHQX/p1725648135173439?thread_ts=1725648135.173439&cid=C03ULMDEHQX
Beta Was this translation helpful? Give feedback.
All reactions