LogoLogo
API Documentation
Version 1.19.5 and Older
Version 1.19.5 and Older
  • DecisionRules Documentation
  • API
    • API Introduction
    • API Keys
      • Solver API Keys
      • Management API keys
      • BI API keys
    • Rule Solver API
    • Management API
      • Deprecated Endpoints
    • Console Logs API
    • Business Intelligence API
      • Deprecated Endpoints
    • Datacenters & Locations
      • Global Cloud
      • Regional Cloud
    • Apache Kafka Solver API
    • Endpoint Settings
    • Archive
      • Rule Flow Solver API (DEPRECATED)
  • Decision tables
    • Decision Tables Introduction
    • Table Designer
    • Input & Output JSON Model
      • Simple Editor
      • JSON Editor
      • Binding to Model
    • Supported Data Types
    • Operators and Functions
      • Basic operators
      • Date operators
      • Functions
        • Logical Functions
        • Math Functions
        • Date and Time Functions
        • Text Functions
        • Data Functions
        • Array Functions
        • Integration functions
        • Functions and JSON
    • Export & Import of Decision Tables
      • Export Decision Table
      • Import Decision Table
      • File Structure of JSON Format
      • Managing Decision Table in Excel/Google Sheets
      • Deprecated Formats: XLSX v.1 and CSV
    • Table Operations
      • Filter Values
      • Valid Values
      • Sorting
  • Decision Trees
    • Decision Trees Introduction
    • Decision Tree Designer
    • Export & Import Decision Trees
      • Export Decision Tree
      • Import Decision Tree
  • Scripting Rules
    • Scripting Rule Introduction
    • Custom functions in Scripting Rules
    • Calling external API within ScriptingRules
    • Use Rule Variables in Scripting Rules
    • Call Embedded Rules in Scripting Rules
    • Export & Import Scripting Rules
      • Export Scripting Rule
      • Import Scripting Rule
    • Tips
  • Rule Flow
    • Rule Flow Designer
    • Rule Flow Mapping
    • Rule States in Rule Flow
    • Warnings & Errors
    • Rule Flow Limits
    • Export & Import Rule Flows
      • Export Rule Flow
      • Import Rule Flow
  • Workflow
    • Workflow Introduction
    • Workflow Designer
    • Workflow Nodes Overview
    • Workflow Limits
  • Other
    • Rule Alias
    • Execution Strategy
    • Rule State
    • Rule Versioning
    • Favorite Rules
    • Rule Variables
    • Rule Comparison
      • Decision Table Comparison
      • Decision Tree Comparison
      • Scripting Rule Comparison
    • Rule Tags
    • Rule Dependencies
    • Test Bench
    • Single Sign-On (SSO)
    • Event timeline
    • Rule Lock
    • Rule Migration Strategies
    • Changes in Version 1.19.0 (10/2024)
  • Organizations
    • Introduction
      • Access to Organization
    • Structure
      • Organization Roles
      • Members
      • Teams
      • Spaces
      • Space Roles
      • Policies
      • Settings
  • Teamwork
    • Dashboard
    • Folders
    • Spaces
    • Manage Spaces
    • Share Rules Between Spaces
    • Users & Roles
    • Teamwork Indicator
  • SDK and Integrations
    • Languages / Frameworks
      • SQL Server
      • Oracle PL/SQL
      • PostgreSQL
      • JavaScript
      • Java Spring Example
      • PHP Library
      • Python Library
      • .NET Library
      • Google Tag Manager
    • Excel Add-in
  • Business Intelligence
    • Audit Logs
    • Create a Power BI Report
    • Connect Power BI to Business Intelligence API
    • Connecting from Power BI (deprecated)
    • Connect DecisionRules to Power BI Using Our Custom Connector
  • Billing
    • Invoices & Billing
    • Change Product Plan
    • Billing Information
    • Plan Limits Explained
  • Regional Cloud
    • Regional Cloud
    • Region Specific API URLs
  • On-Premise / Docker
    • Environment Variables
    • Redis Connection Modes
    • Setup Single Sign-On (SSO)
      • Set up Microsoft Entra ID SSO
      • Set up Google SSO
    • DecisionRules Application
      • Minimal Requirements
      • DecisionRules Server
      • DecisionRules Client
      • DecisionRules Business Intelligence
      • Networking Between Docker Containers
    • Docker Showcase App
      • Showcase
      • Showcase + Business Intelligence
    • AWS Setup
      • AWS ECS/Fargate
      • Cache - Amazon ElastiCache
    • Microsoft Azure Setup
      • Database - Azure CosmosDB
      • Cache - Azure Cache for Redis
      • Azure Container Apps
    • Azure Red Hat OpenShift
    • Google Kubernetes Engine (GKE)
    • Kubernetes Setup
      • Kubernetes Setup with Business Intelligence
    • Logging options
    • CD/CI Pipelines
      • Azure DevOps CICD Pipelines
      • Using Migration script (old way)
    • Offline License
  • Terms & Conditions
    • Terms and Conditions
    • Privacy Policy
    • Service Level Agreement
      • Community Support
      • Standard Cloud (SaaS)
      • Silver SLA
      • Gold SLA
      • Custom SLA
    • Sub-Processor List
  • Roadmap 🚲 🗺️
  • Release Notes
    • Public Cloud
    • On-Premise / Private Cloud
Powered by GitBook
On this page
  • Overview
  • Placement as key and value
  • Placement inside an array
  • Variables
  • Functions
  • Combinations
  • Example
  • More examples

Was this helpful?

  1. Decision tables
  2. Operators and Functions
  3. Functions

Functions and JSON

Was this helpful?

DecisionRules supports mixing native functional expressions with JSON. On this page, we will shortly explain how to write these mixed functional/JSON expressions and provide one realistic example of their usage.

Overview

In this section we give a brief overview of all the supported types of mixed functional/JSON expressions together with examples and recommendations for their use.

Placement as key and value

Functional expressions can be passed as a value into an object.

{"animal":{data}}

They can also define the key.

{{data}:["dog","cat","bird"]}

Since JSON only allows strings as keys, make sure that the dynamically generated key evaluates to a string. If not, it will be automatically casted to string, which might not make good sense. Also note that the key must be unique within the object.

Placement inside an array

Functional expressions can also represent an element of an array.

["dog",{data},"bird"]

Variables

In the above examples, we have passed a variable data inside the JSON. This can be any kind of supported within functions. Mixed expressions even work with abstract function variables:

ARRAY_MAP({data}, "letter", {"letter": {letter}})

Functions

We can of course use functions.

{"average": AVG(10,30)}
{1+2:"three"}

Combinations

The above listed types of expressions can be arbitrarily combined.

{"animals": {data}, "number": COUNT({data})}

Example

Suppose you have a rule Delivery Price with alias delivery-price which gives you the price of delivery based on package weight. Its input model is

{
  "package": {
    "weight": {}
  }
}

and the output model is

{
  "price": {},
  "currency": {},
  "deliveryInHours": {}
}
SOLVE("delivery-price", {"package": {"weight": 12}})

Note that the object in the second argument of the SOLVE function corresponds to the input model of our Delivery Price rule. This is because it supplies the input data for it. The SOLVE function evaluates the rule and returns the output, which may look like this:

[
  {
    "price": 28,
    "currency": "USD",
    "deliveryInHours": "24 Hours"
  }
]

The interesting part comes when we want to pass some dynamic data to our Delivery Price rule. For example, imagine we have an input variable packageWeight and want to solve Delivery Price with the value from this variable. We can do that by simply writing the variable inside to the object:

SOLVE("delivery-price", {"package": {"weight": {packageWeight}}})

The variable packageWeight will be automatically interpreted and passed to the object, which will be then picked up by the SOLVE function and used as input for the Delivery Price rule.

But we can do much more than this. The JSON can be also mixed with arbitrary functions. For example, imagine we want to limit the packageWeight to be always greater than 10 before passing it to the SOLVE function. No problem, just write the appropriate function expression:

SOLVE("delivery-price", {"package": {"weight": MIN(10,{packageWeight})}})

Following this logic, it is possible to mix arbitrary functional expressions and JSON to get the desired behavior.

More examples

The below provided decision table contains examples of functions with JSON. Import the decision table to your space to see them working.

Now, imagine we wish to call this rule from a decision table. We can easily do that with the function. In the respective output cell where we want to get the result, we can write something like

Of course, the exact form and data returned depends on the Delivery Price rule itself. We could now take this output, process it with the help of or and return it in the outputs or use it in our next steps.

Data Functions
Array Functions
variable
SOLVE
26KB
JSON_Example_v1.json