Erlang parser implementation for the JSONata transform language.
JSONata plays a central role in Node-RED - the low-code visual flow-based programming environment.
This is an implementation for the Erlang-RED codebase. Erlang-RED is the low-code visual flow-based programming environment inspired by Node-RED!
What is flow based programming? A programming paradigm focussed on message passing between independent computational units.
This library transforms JSONata stanzas into valid Erlang code which are intended to be executed in the presence of a Msg
map.
For example:
$$.payload.fuba.dad + 1 + 2 + $$.payload.name.name + 3 + 4 * 6
becomes:
fun (Msg) ->
maps:get(dad, maps:get(fuba, maps:get(payload, Msg))) + 1 + 2 +
maps:get(name, maps:get(name, maps:get(payload, Msg))) + 3 + 4 * 6
end.
At the time of writing, this library supports a minimum set of functionality of the original JSONata language. Of all the functions plus the Node-RED extensions, this supports:
Function | Comment |
---|---|
$count | Supported |
$keys | Supported |
$length | Supported |
$map | Supported |
$millis | Supported - including the requirement that multiple calls produce the same value |
$replace | Supported but no regular expressions |
$split | Supported |
$string | Supported |
$sum | Supported |
$pauseMillis | Erlang-RED special: pause this many milli seconds |
$toString | Erlang-RED special basically the same as $string |
Functions are defined in two places in the parser or in the evaluator.
There is no particular timeline to extend that list, functionality is being added as needed by the flow tests the define the current behaviour of existing Node-RED nodes.
$ rebar3 compile
$ rebar3 eunit