'Display the data value after using jsonata

This is my json { "message":{ "Refno":"654" } } This is my jsonata file message.{ "data":"update/add", "Refno":($.data=update)?Refno:"" }

If in jsonata the data value is update I need a Refno is 654 otherwise it will print empty string Please help me out above jsoncade is not working



Solution 1:[1]

I believe this is the proper JSONata expression for your problem:

message.{ "data": $$.data, "Refno": ($$.data="update" ? $.Refno : "") }

Note that I'm using $$ to get the root of a document in an expression, check out https://docs.jsonata.org/programming#built-in-variables for more details.

By the way, I’ve built this solution in 2 minutes by using the Mappings tool that my team is building at Stedi.

A screenshot of Mappings tool developed by Stedi

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tomasz ?akomy