In this article
You can use this Snap to generate a JSON document for the next Snap in the Pipeline.
None.
Works in Ultra Pipelines.
Input/Output | Type of View | Number of Views | Examples of Upstream and Downstream Snaps | Description |
---|---|---|---|---|
Input | Document Retain one. |
|
| This Snap can have an upstream Snap that can pass a JSON document in output view. |
Output | Document Retain one. |
|
| This Snap generates a document that contains the expected result along with the original JSON document (when Pass through is enabled). |
Parameter Name | Data Type | Description | Default Value | Example |
---|---|---|---|---|
Label | String | N/A | JSON Generator | |
Edit JSON | Apache Velocity template | Optional. Launches the JSON editor which will allow defining JSON. The editor will load an existing JSON document if it was defined previously. The editor lets you save JSON in SnapLogic's file system or import existing JSON documents from it. Note that this text is treated as an Apache Velocity template, so you can substitute values from input documents or the pipeline parameters. The Apache Velocity template can be used to pass dynamic values from upstream Snaps. For more information, see | Empty JSON file | File with JSON content |
Process Array | Checkbox | Optional. The Process array property specifies whether or not the Component should take a root JSON array and write each element of the array as a JSON document. | Selected | Selected |
Pass through | Checkbox | Optional. Use this property to pass the data in the input document through to the output document and merge it under the key 'original'. See example for more details. | Deselected | Selected |
Checkbox | Deselected | Selected | ||
String | Indicates how the Snap must be executed. Available options are:
| Validate & Execute | Execute only |
Error | Reason | Resolution |
---|---|---|
Unexpected character ('{' (code 123))Enter the error message that is displayed. | The array entries in the JSON file do not follow the syntax. A comma ',' is expected before the beginning of every second array—'{'. Briefly describe why this error is triggered. An experienced user will be able to troubleshoot the error looking at the reason itself. | Verify the array at the row and column mentioned beside the error message using the Edit JSON feature and add a comma appropriately. List the steps that the user must take, if necessary, to rectify this error. If a procedure is extensive, add it as a separate section after this table and reference it with a link in this cell. |
Clicking Edit JSON will launch the JSON Editor. The JSON will be stored in the Snap (after clicking OK). The JSON can be exported to SnapLogic's file system using the export action or be imported from there using the import action.
The JSON can be customized to meet specific needs, such as having:
Additionally, some special characters can be escaped using the following notations.
Type | To pass this value | Specify |
---|---|---|
Single characters | $ | #[$]# or \$ |
JSON String | ## | #[##]# |
For information on how to use pipeline parameters and field values within this Snap, see Velocity Templates in Generator Snaps in Parameters and Fields.
Consider the following Pipeline that combines two simple datasets.
JSON Object (JSON Generator Snap with Pass through disabled)
This JSON Generator Snap, JSON Object, is used as an input by the downstream JSON Generator Snap, Combined JSON.
Snap Configuration (JSON Object) | |
---|---|
Input JSON | Output JSON |
Combined JSON (JSON Generator Snap with Pass through enabled)
Snap Configuration (Combined JSON) | |
---|---|
Input JSON | Output JSON |
The output JSON contains:
This example Pipeline demonstrates the difference in the input schema types on selecting and deselecting Support Type Extensions checkbox.
There is no difference in the preview output of JSON Generator or JSON Parser as the JSON representation remains the same. But the Mapper Snaps downstream of the JSON Generator Snap shows the difference in the Input Schema types.
The input schema in Mapper Snap when you deselect Support Type Extensions checkbox in the JSON Generator Snap is as follows. The Snap displays the SnapLogic-specific syntax in the Input Schema.
Here's the same Mapper Snap when you select the Support Type Extensions checkbox. Note the data types in the Input Schema—the Snap does not display the SnapLogic-specific syntax in the Input Schema.
Similarly, here's a Mapper Snap showing the JSON Parser output when you deselect the Support Type Extensions checkbox.
Here's the same Mapper when you select the Support Type Extensions checkbox.
The Support Type Extensions state affects the JSON Formatter's output. When you deselect this checkbox, the SnapLogic-specific syntax is not used; the Snap uses a string representation for each of the special objects.
Here's the output when you select the Support Type Extensions checkbox:
|