Skip to main content

JSON Decision Model (JDM)

JDM is a modeling standard for business decisions and business rules and is represented by graphs. Graphs are built using nodes and edges. Edges are used to pass the data from one node to another (left-side to right-side).

Input node contains all data sent in the context, and Output node returns the data from the decision. Data flows from the Input Node towards Output Node evaluating all the Nodes in between and passing the data where nodes are connected.

You can try Free Online Editor

JSON Decision Model

JSON Example

Decision Tables

Decision table is a node which allows business users to easily modify and add new rules in an intuitive way using spreadsheet like interface. The structure of decision table is defined by its schema. Schema consists of inputs and outputs.

Decision tables are evaluated row by row from top to bottom, and depending on the hit policy a result is calculated.

Inputs

Input fields are commonly (qualified) names for example cart.total or customer.country.

{
"cart": {
"total": 1000
},
"customer": {
"country": "US"
}
}

Inputs are using business-friendly ZEN Expression Language. The language is designed to follow these principles:

  • Side-effect free
  • Dynamic types
  • Simple syntax for broad audiences

List shows basic example of the unary tests in the Input Fields:

Input entryInput Expression
"A"the field equals "A"
"A", "B"the field is either "A" or "B"
36the numeric value equals 36
< 36a value less than 36
> 36a value greater than 36
[20..39]a value between 20 and 39 (inclusive)
20,39a value either 20 or 39
<20, >39a value either less than 20 or greater than 39
truethe boolean value true
falsethe boolean value false
any value, even null/undefined
nullthe value null or undefined

Note: For the full list please visit Expression Language docs.

Outputs

The result of the decisionTableNode evaluation is:

  • an object if the hit policy of the decision table is FIRST and a rule matched. The structure is defined by the output fields. Qualified field names with a dot (.) inside lead to nested objects.
  • null/undefined if no rule matched in FIRST hit policy
  • an array of objects if the hit policy of the decision table is COLLECT (one array item for each matching rule) or empty array if no rules match

Example:

Screenshot 2023-03-10 at 22 57 04

And the result would be:

{
"flatProperty": "A",
"output": {
"nested": {
"property": "B"
},
"property": 36
}
}

Functions

Function nodes are JavaScript lambdas that allow for quick and easy parsing, re-mapping or otherwise modifying the data. Inputs of the node are provided as function's arguments. Functions are executed on top of Google's V8 Engine that is built in into the ZEN Engine.

const handler = (input) => {
return input;
};

Decision

Decision is a special node whose purpose is for decision model to have an ability to call other/re-usable decision models during an execution.