I am using Jsonata and I am stuck somewhere in the middle. Basically, I receive from a JSON a property called EMAIL: "[email protected]|2|bb@bb-com|4|" . In this format, using Jsonata I need to transform this into
Tried many solutions, but got mainly 5 objects lol. Would appreciate if I can get some help. Also number of emails is not the same always, so would need something dynamic.
INPUT "[email protected]|2|bb@bb-com|4|"
OUTPUT
[ { "email":[email protected] "score":4 "position":1 }, { "email":[email protected] "score":2 "position":2 } ]
There might be multiple ways to solve it, but I would use the reduce function after splitting by "|":
Check it out on the Stedi Playground: https://stedi.link/EG3UGjw