Available from version: 1.0.101
The toJson function set allows to generate a JSON text string based on the entered values or form variables in the function parameters. With these functions at our disposal, we are able to create any JSON with an unlimited number of nests in a text string. To create a JSON string as an object, the toJsonObject() function is used. If we want to create a JSON string in the form of an array, use the toJsonArray() function. The last function that complements the JSON generation capabilities is toJsonArrayIterator(), which allows to create JSON as an array of objects. The most important feature of this function is the ability to map dynamic table (variable set) rows to an array of objects. For this, it is necessary to use the item () function in the function configuration parameters.
- toJsonObject()
Name of the parameter | From version | Description | Parameter type | Default value | Field type | Notes and restrictions | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Key | 1.0.101 | Name of the key written in quotation marks in the resulting JSON | Table text values | Editable field | ||||||||||||||||
Value | 1.0.101 | Specifies the key value. It is separated by a colon from the key in the resulting JSON | Table text values | Editable field | If a text value has been specified for a given value in the Type parameter, it will be enclosed with quotation marks. There will be no quotation marks for integer, floating point, and logical types. For the object type, the value will be provided with {} braces, and for array type with square brackets []. | |||||||||||||||
Type | 1.0.101 | Type of the stored value | Table text values | Non editable dropdown list |
For floating point values, use a dot as a decimal separator (English standard). Type with the value Object allow to use only toJsonObject() function in the Value field, and the type with the value Array only allow to use toJsonArray() or toJsonArrayIterator() functions. |
- toJsonArray()
Name of the parameter | From version | Description | Parameter type | Default value | Field type | Notes and restrictions | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Value | 1.0.101 | Specifies a single array value | Table text values | Editable field | If a text value was specified for the values in the Type parameter, they will be enclosed with quotation marks. There will be no quotation marks for integer, floating point, and logical types. For the object type, the values will be enclosed with braces {}, and for array type with square brackets []. | |||||||||||||||
Type* | 1.0.101 | type of the stored values | Text | Non editable dropdown list |
For floating point values, use a dot as a decimal separator (English standard). Type with the value Object allow to use only toJsonObject() function in the Value field, and the type with the value Array only allow to use toJsonArray() or toJsonArrayIterator() functions. |
- toJsonArrayIterator()
Name of the parameter | From version | Description | Parameter type | Default value | Field type | Notes and restrictions | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Function* | 1.0.101 | Function result is a single array value. The function will be executed as many times as is the length of the array, that is, the value entered into the parameter Table length. | Function | Editable field | ||||||||||||||||
Table length* | 1.0.101 | Value that specifies the length of the table. Defines how many times the iteration will be performed. | Integer | Editable field | ||||||||||||||||
Counter* | 1.0.101 | Variable on the form that stores the value of the current iteration. | Variable | Editable field | After the iteration loop completes, the counter is reset to zero. | |||||||||||||||
Type* | 1.0.101 | Type of the stored values | Text | Non editable dropdown list |
For floating point values, use a dot as a decimal separator (English standard). Type with the value Object allow to use only toJsonObject() function in the Function field, and the type with the value Array only allow to use toJsonArray() or toJsonArrayIterator() functions. |
Parameter*- required field
It is worth considering that using the toJsonArray () function you can also build a JSON consisting of an array of objects, but you cannot reflect the contents of a dynamic table (variable set) from the form in this array. The toJsonArrayIterator () function allows this, because it iterates over the elements of a dynamic table.
- toJsonObject()
name:
expenses:
- toJsonArray()
- toJsonArrayIterator()
Function:
company name:
national court register:
tax exempt number:
- toJsonObject() and toJsonArray()
Function parameters configuration:
name:
expenses:
Result:
{ "identifier": "adampastewski", "index": 11279, "interest": 2.5, "appliesToVAT": true, "name": { "firstname": "Adam", "lastname": "Pastewski" }, "expenses": [ 122.6, 130.1, 58.7 ] }
- toJsonArrayIterator()
Generating a list of objects based on the following data:
Function parameters configuration:
Function:
date:
amount:
symbol:
value:
features:
TAX:
MPK:
Projects:
Project task:
Result:
[ { "date": "2020-12-15", "VAT rate": "23%", "applies to VAT": true, "mark": "1001", "amount": { "symbol": "PLN", "value": 4867.5 }, "features":[ { "name":"TAX", "value":83 }, { "name":"MPK", "value":143 }, { "name":"Projects", "value":117 }, { "name":"Project task", "value":2201 } ] }, { "date":"2020-12-17", "VAT rate":"23%", "appliesToVAT":true, "mark":"1001", "amount":{ "symbol":"USD", "value":1351.4 }, "zestawy":[ { "name":"TAX", "value":92 }, { "name":"MPK", "value":145 }, { "name":"Projects", "value":152 }, { "name":"Project task", "value":89 } ] } ]
1.0.101
- Adding functions