JSON Generator (Mock)
Discover more about the JSON Generator (Mock) connector and how to use it on the Digibee Integration Platform.
JSON Generator (Mock) creates a JSON object. This connector accepts any input.
Parameters
Take a look at the configuration options for the connector. Parameters supported by Double Braces expressions are marked with (DB)
.
JSON (DB)
The JSON object that will be the output of the connector.
N/A
JSON Object
Fail on Error
If the option is activated, the pipeline's execution with an error will be interrupted. Otherwise, the pipeline execution proceeds, but the result will show a false value for the "success"
property.
False
Boolean
Using Global variables
Global variables can be retrieved in the JSON Generator (Mock) connector using the following Double Braces expression:
{{global.global-name}}
You can retrieve Globals in two ways:
As a string
As a number
Retrieving Global variables as a string
If the Global variable’s value is a string, regardless of its category, you must enclose the Double Braces expression in double quotes.
For example, suppose you create a Global named global-email under the Email category and set an email address as its value. The Platform will interpret this value as a string. Therefore, to retrieve this Global variable in the JSON Generator (Mock) connector, structure the expression as follows:
{
"email": "{{global.global-email}}"
}
If you don’t enclose the expression in double quotes, you will receive the following error:
{
"timestamp": 1738778741919,
"error": "An internal error has occurred. Exception: com.digibee.pipelineengine.exception.PipelineEngineRuntimeException: Could not parse double braces parameter json due to JSON exception: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'email': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n at [Source: (String)\"{\n \"email\": [email protected]\n}\"; line: 2, column: 17]",
"code": 500
}
This rule applies to any Global variable with a string value.
Retrieving Global variables as a number
If the Global variable’s value is a number, don’t enclose the Double Braces expression in double quotes. Otherwise, the number will be treated as a string.
For example, suppose you create a Global named global-id under the ID category and set its value to 1234.
To retrieve this Global variable as a number in the JSON Generator (Mock) connector, structure the expression as follows:
{
"id": {{global.global-id}}
}
The output will be:
{
"id": 1234
}
However, if you need to retrieve it as a string, simply enclose the expression in double quotes:
{
"id": "{{global.global-id}}"
}
This will return:
{
"id": "1234"
}
Usage example
In this example, we used the JSON Generator (Mock) connector to modify someone’s data. Here, we want to join the firstName
and lastName
properties into a single property called fullName
. We also want to delete the phoneNumber property and add a property called country, which has the value “Brazil”.
Input
{
“firstName” : “Carlos”,
“lastName” : “Silva”,
“phoneNumber” : “+55(11)99999-8888”
}
Parameter settings
We use the JSON Generator (Mock) connector with the following JSON parameter configuration:
{
"fullName" : {{ CONCAT(message.firstName," ", message.lastName) }},
"country" : "Brazil"
}
Here, we used the CONCAT Double Braces function to join the first and last names, with a blank space between them.
Output
{
"fullName": "Carlos Silva",
"country": "Brazil"
}
Last updated
Was this helpful?