On this Page

Snap type:

Read


Description:

This Snap generates JSON as a document for the next Snap in the pipeline. It is often used at the beginning of a pipeline to create a file. The file size has a limit of 16 MB for JSON.


Prerequisites:

[None]


Support and limitations:

Works in Ultra Pipelines.

Account: 

Accounts are not used with this Snap.


Views:


InputThis Snap has at most one document input view.
OutputThis Snap has exactly one document output view.
Error

This Snap has at most one document error view and produces zero or more documents in the view.

If the Snap fails with an error in the JSON, an error document is sent to the error view containing the fields error, original, and templateOutput:


{
    "error": "Unexpected character ('{' (code 123)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: JSON Generator; line: 4, column: 2]",
    "original": null,
    "templateOutput": "\n[\n    {\n{\n    }\n]\n\n\n"
  }


Settings

Label


Required. The name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline.

Edit JSON


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. See the following URL for more information about Velocity:
https://velocity.apache.org/engine/devel/user-guide.html

Process array 

Required. The Process array property specifies whether or not the Component should take a root JSON array and writes each element of the array as a JSON document. 

Example: Selected 

Default value: Selected 




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: 
1) having static content that produces one output document or  

2) having a list of static documents within an array definition which can then be transformed into multiple documents upstream by using a JSON Splitter Snap or 


 

 
3) having variables in the JSON, which can be substituted with document values from the input view of
the Snap. 

Additionally, some of the characters can be escaped using #[]# (for a JSON string) or \ (for a single character):

  • For example, to escape ##, you specify #[##]#
  • For example, to escape $, you specify #[$]# or \$

For information on how to use pipeline parameters and field values within this Snap, see the "Velocity Templates in Generator Snaps" section of Parameters and Fields.