Learn about JSON functions in the Digibee Integration Platform and how to use them.
The functions were created to:
Speed up the creation of your integrations even more.
Decrease the complexity of your pipelines.
Simplify data conversions and transformations during the flow of your pipelines.
The JSON functions make operations in JSON objects and are available for components that support Double Braces expressions. To know how to provide information to the components using this resource, refer to Double Braces Functions.
JSONPATH
This function in Double Braces returns parts of a determined document according to the sent expression.
Syntax
JSONPATH(value:string, expression:string)
value: string
expression: string containing the expression to be recovered
Let's say you need to obtain part of a document using expressions. The document contains the following information, which can be passed through the output of the last component or the payload:
{"store": {"book": [ {"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95 }, {"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99 }, {"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99 }, {"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99 } ] }}
{"test": [ {"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99 }, {"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99 } ],"test2": {"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95 }}
It's possible to use the functions that JSONPATH internally provides, such as:
If the array is empty, the result will be the same empty array.
NEWEMPTYOBJECT
This function allows you to create a new empty object.
Syntax
NEWEMPTYOBJECT()
Let's say you need to create a new empty object:
{"data": { }}
Creating:
{"data": {{ NEWEMPTYOBJECT() }}}
The result will be:
{"data": { }}
NEWEMPTYARRAY
This function allows you to create a new empty array.
Syntax
NEWEMPTYARRAY()
Let's say you need to create a new empty array:
{"data": [ ]}
Creating:
{"data": {{ NEWEMPTYARRAY() }}}
The result will be:
{"data": [ ]}
CARDINALITYONE
The function allows a cardinality of n:1 to be applied to any informed structure, where regardless of the number of elements in the input, the output will always be 1 element.
Syntax
CARDINALITYONE(data)
Let's say you need to apply a n:1 cardinality on each element from the JSON below:
This function allows an output to be standardized by a multiple cardinality. That means, when an input of an array has n elements, its output will be an array of n elements, and when an input has a sole object, its output will be an array of this same object.
Syntax
CARDINALITYMANY(data)
Let's say you need to apply a m:n cardinality to each element from the JSON below: