Webhook:How to write Conditional logic(if/else kind) of payload received in customized payload of Webhook?

Use Case:
I want to write a logic for the payload received when webhook is triggered.
for eg:
If { /payload/fields/x } is not null then give {/payload/sys/id} in customized payload.