JSONata Processor
7 min
the jsonata processor transforms incoming json payloads using a jsonata expression you define, letting you reshape, filter, or combine fields from one or more inputs without writing custom code why use the jsonata processor use this processor when you need to query or restructure json data with jsonata's expression language, for example, extracting and renaming fields from a device payload, or combining fields from multiple inputs into a new shape how it works write your jsonata expression in the code editor, which supports syntax highlighting and real time validation from the editor, you can also access fullscreen to show the code editor in full screen mode playground to test, write, and validate your expression in real time before deploying it validate to check your expression's syntax event wires versus value wires the wire type you connect determines how your expression addresses the input with an event wire you reference incoming fields directly by name with no wire name prefix you can connect multiple event wire inputs to one jsonata processor but each is processed independently and generates its own output payload with a value wire every field is prefixed with its wire name the processor waits until every connected value wire input has produced a payload before it produces output, holding earlier payloads in memory until the later ones arrive examples using event wires as input when using the event wire type, there is no need to specify the wire name when defining the fields in the jsonata expression you can define multiple inputs into a single jsonata process however, each input is considered as it’s own process flow and generates a new payload input payload { "datatype" "float64", "description" "", "deviceid" "75f601ca 0f7a 4c26 90f0 470e2424bac1", "devicename" "gen", "metadata" {}, "registerid" "d5dcf52f 342b 4211 8f4f b92e4406bc4c", "success" true, "tagname" "tag1", "timestamp" 1739558895577, "value" 0 38164469548275337 } jsonata expression in this example, you simply define the field name from the input in the expression { "metric" $substring(tagname,3), "value" value, "date" $frommillis(timestamp, '\[m01]/\[d01]/\[y0001] \[h#1] \[m01]\[p]') } output payload { "date" "02/14/2025 6 51pm", "metric" "1", "value" 0 38164469548275337 } using value wires as input when using the value wire type, every input field must be a prefix wire name the jsonata processor will not produce a payload until all input payloads are present for example, the payload from input 1 is stored in memory until input 2 produces a payload input payload 1 // wirename = input 1 { "datatype" "float64", "description" "current metric", "deviceid" "75f601ca 0f7a 4c26 90f0 470e2424bac1", "devicename" "gen", "metadata" {}, "registerid" "d5dcf52f 342b 4211 8f4f b92e4406bc4c", "success"\ true, "tagname" "tag1", "timestamp" 1739558895577, "value" 0 38164469548275337 } input payload 2 //wirename = input 2 { "datatype" "float64", "description" "temp metric", "deviceid" "75f601ca 0f7a 4c26 90f0 470e2424bac1", "devicename" "gen", "metadata" {}, "registerid" "d5dcf52f 342b 4211 8f4f b92e4406bc4c", "success"\ true, "tagname" "tag2", "timestamp" 1739558895577, "value" 1 8813568907902232 } output payload { "metric 1" tsg1, "metric 2" tag2, "value 1" 0 38164469548275337, value 2" 1 8813568907902232, "date" "date" "02/14/2025 6 51pm" }