diegoholiveira / jsonlogic

Go Lang implementation of JsonLogic
MIT License
155 stars 46 forks source link

Support for object return types #58

Closed tlugger closed 2 years ago

tlugger commented 2 years ago

A rule map containing more than 1 key should count as a primitive value and be returned by calling Apply. However, this is not currently the case in this package. Instead, any instance of a map parsed through recursive apply calls will continue to recurse until a primitive value is parsed and returned. An example of this case:

Rule:

{"if":[ 
    {"==":[{"var":"foo"},"bar"]},{"foo":"is_bar","path":"foo_is_bar"},
    {"foo":"not_bar","path":"default_object"}
]}

Data:

{"foo": "bar"}

The expected return value here is the full object {"foo":"is_bar","path":"foo_is_bar"} which is the case in the jsonlogic playground: https://jsonlogic.com/play.html

However, this currently is parsed to a boolean value true