Reputation: 5
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
Upvotes: 0
Views: 730
Reputation: 261
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.
Upvotes: 2