◷ Reading Time: 3 minutes
Native Complex Value is a representation of hierarchical values. Since v7 of FlexRule you can define array (or collections) using [ and ]. Also you can define key/value pairs using { and }.
The combination of using a native array and key/value pairs allows you to define complex hierarchical values.
Key Value Pair
To define a key-value pair follow the below format:
Format: { name: value }
- name: defines key name. can be enclosed with single/double quotes (‘ or “) if it includes spaces.
- value: defines a value as a valid FlexRule expression
Example:
{Name: 'Arash', Family: 'Aghlara'}
Array
Native array supports simple values and Native complex values by separating them with a comma (,) and putting the between [ and ].
[1,3,'testing string', #2010/1/1#]
or for native complex values:
[ {Name: 'Arash'}, {Name: 'Goli'}, [10, 20, 30], 'Australia', #2010/1/1# ]
As you see in the above example, they can be nested and contain other native complex values.
JSON
A JSON can be consider a simple form of a native complex value. This capability allows FlexRule to understand JSON objects natively.
{ Name: 'Arash', Family: 'Aghlara', Company: { Name: 'FlexRule', FoundedAt: 2008 } }
Complex Value
One of the benefits of native complex value is it allows you to have an extended, dynamic hierarchical values, which opposite to JSON, it does not limit you only on the JSON standard (supported) value types:
- Support richer value types in the hierarchy (i.e. DataTime, Timespan…)
- Support variables as part of the hierarchy
- Support computational values for the values in the hierarchy
{ CreatedAt: now(), Name: n, Address: { Line1: address.Line1 }, IsValid: n!=null and a>0 and address.Line1!=null, Birthday: #1967/12/27# }