JSON Generator

Overview

You can use this Snap to generate a JSON document for the next Snap in the pipeline.
  • This Snap is often used at the beginning of a pipeline to create a file.
  • This Snap does not need any accounts.

JSON Generator Configuration Settings

Prerequisites

  • A valid account with the required permissions.

Limitations and known issues

None.

Snap views

View Description Examples of upstream and downstream Snaps
Input This Snap can have an upstream Snap that can pass a JSON document in output view. Mapper

Copy

Output This Snap generates a document that contains the expected result along with the original JSON document (when Pass through is enabled). Mapper

Copy

JSON Formatter

Error

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the pipeline by choosing one of the following options from the When errors occur list under the Views tab. The available options are:

  • Stop Pipeline Execution Stops the current pipeline execution when an error occurs.
  • Discard Error Data and Continue Ignores the error, discards that record, and continues with the remaining records.
  • Route Error Data to Error View Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap settings

Legend:
  • Expression icon (): Allows using JavaScript syntax to access SnapLogic Expressions to set field values dynamically (if enabled). If disabled, you can provide a static value. Learn more.
  • SnapGPT (): Generates SnapLogic Expressions based on natural language using SnapGPT. Learn more.
  • Suggestion icon (): Populates a list of values dynamically based on your Snap configuration. You can select only one attribute at a time using the icon. Type into the field if it supports a comma-separated list of values.
  • Upload : Uploads files. Learn more.
Learn more about the icons in the Snap settings dialog.
Field / Field set Type Description
Label String

Required. Specify a unique name for the Snap. Modify this to be more appropriate, especially if more than one of the same Snaps is in the pipeline.

Default value: JSON Generate

Example: Document generate
Edit JSON Button Launches the JSON editor which allows you to define JSON. The editor loads an existing JSON document if defined previously. The editor lets you save JSON in SnapLogic's file system or import existing JSON documents from it. You can substitute the variables in the JSON with document values from the input view of the Snap.
Note: The JSON 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.
You can customize the JSON file to:
  • Generate static content that produces one output document.
  • Generate a list of static documents within an array definition which can then be transformed into multiple documents upstream by using a JSON Splitter Snap.
Process Array Checkbox 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.

Default status: Selected

Pass through Checkbox Use this property to pass the data in the input document through to the output document and merge it under the key 'original'.
Note: Do not select this property if the input data is not in JSON lines format. If it has no newline character and its data size exceeds available memory, it may cause an out of memory error.

Default status: Selected

Support Type Extensions Checkbox Select this checkbox to enable the Snap to format/parse the Snaplogic-specific syntax indicating objects of the special types, such as byte arrays and date objects in JSON. For more information, see the Input Schema Types example.
Snap execution Dropdown list
Choose one of the three modes in which the Snap executes. Available options are:
  • Validate & Execute: Performs limited execution of the Snap and generates a data preview during pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.
  • Execute only: Performs full execution of the Snap during pipeline execution without generating preview data.
  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Default value: Validate & Execute

Example: Execute only

Troubleshooting

Unexpected character ('{' (code 123)

Possible Causes

The array entries in the JSON file do not follow the syntax. A comma ',' is expected before the beginning of every second array—'{'.

Possible Solutions

Verify the array at the row and column mentioned beside the error message using the Edit JSON feature and add a comma appropriately.