LogoLogo
API Documentation
Current Version
Current Version
  • DecisionRules Documentation
  • DecisionRules Academy
  • API
    • API Introduction
    • API Keys
      • Solver API Keys
      • Management API keys
      • BI API keys
    • Rule Solver API
    • Management API
      • Rule Migration Strategies
      • 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)
  • AI Assistant
    • About Assistant
    • Assistant Setup
      • Gemini Assistant
  • RULES
    • Rules Introduction
    • Rule List
    • Rule Mode
    • Common Rule Features
      • Input & Output Model
        • Simple Editor
        • JSON Editor
      • Test Bench
      • Rule Alias
      • Rule State
      • Versioning
      • Rule Variables
      • Execution Strategy
      • Rule Dependencies
      • Rule Export & Import
        • Rule Export
        • Rule Import
        • Managing Decision Table in Excel/Google Sheets
        • Deprecated Formats: XLSX v.1 and CSV
      • Tags
      • Rule Comparison
        • Decision Table Comparison
        • Decision Tree Comparison
        • Scripting Rule Comparison
      • Rule Lock
      • Teamwork Indicator
      • Event Timeline
    • Data Types & Functions
      • 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
    • Decision Table
      • Table Designer
        • Table Operations
          • Filter Values
          • Valid Values
          • Sorting
      • Binding to Model
    • Decision Tree
      • Tree Designer
    • Workflow
      • Workflow Designer
      • Workflow Nodes Overview
      • Workflow Limits
    • Scripting Rule
      • Custom functions in Scripting Rules
      • Calling external API within ScriptingRules
      • Use Rule Variables in Scripting Rules
      • Call Embedded Rules in Scripting Rules
      • Tips
    • Rule Flow
      • Rule Flow Designer
      • Rule Flow Mapping
      • Rule States in Rule Flow
      • Warnings & Errors
      • Rule Flow Limits
  • SPACE
    • Space Introduction
    • Space Info
    • Dashboard
    • Access
    • API Keys
    • Audit Logs
  • Organization
    • Organization Introduction
    • Organization List
    • Members
    • Teams
    • Spaces
    • Space Roles
    • Policies
    • Statistics
    • Settings
  • Profile
    • Profile Introduction
    • General
    • Dashboard
    • Plans
    • Add-ons
    • Limits
      • Plan Limits Explained
    • Subscriptions
    • Invoices
  • Access
    • Sign Up & Login
    • Invitations & Permissions
    • Single Sign-On (SSO)
  • Business Intelligence
    • Audit Logs
    • Power BI Connectivity
      • 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
  • OTHER DEPLOYMENT OPTIONS
    • Regional Cloud
      • Region Specific API URLs
    • Docker & On-Premise
      • Environment Variables
      • Redis Connection Modes
      • DecisionRules Application
        • Minimal Requirements
        • DecisionRules Server
        • DecisionRules Client
        • DecisionRules Business Intelligence
        • Networking Between Docker Containers
      • Setup Single Sign-On (SSO)
        • Set up Microsoft Entra ID SSO
        • Set up Google SSO
      • 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
      • White Labeling
  • 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
  • Terms & Conditions
    • Terms and Conditions
    • Privacy Policy
    • Service Level Agreement
      • Community Support
      • Standard Cloud (SaaS)
      • Silver SLA
      • Gold SLA
      • Custom SLA
    • Sub-Processor List
  • Product Updates
    • Release Notes
      • Public Cloud
      • On-Premise / Private Cloud
    • Major Updates
      • Changes in Version 1.19.0 (10/2024)
      • Changes in Version 1.20.0 (4/2025)
    • Roadmap
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. RULES
  2. Data Types & Functions
  3. Operators and Functions
  4. Functions

Functions and JSON

Last updated 7 months ago

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