Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

On this Page

Table of Contents
maxLevel2
excludeOlder Versions|Additional Resources|Related Links|Related Information

Snap type:

Parse


Description:

This Snap reads JSON binary data from its input view and parses and writes it as JSON document data to its output view.


Prerequisites:

[None]


Support and limitations:

Works in Ultra Task Pipelines

Account: 

Accounts are not used with this Snap.

Views:


InputThis Snap has exactly one binary input view, where it gets the JSON binary data to be parsed.
OutputThis Snap has exactly one document output view, where it provides the JSON document data stream.
Error

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

If the Snap fails during the operation, an error document is sent to the error view containing the fields error, reason, original, resolution, and stack trace:

Code Block
{ 
error: "Cannot parse JSON data"
reason: "Unable to create json parser for the given input stream, Unexpected character ('F' (code 70)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')"
original:  {cache-control:no-store, content-type:text/csv; charset=utf-8, connection:keep-alive, last-modified:{, ...}, etag:W/6c206b5eb3f9f13535158ad7cd09c951, content-length:236, content-dis...} 
resolution: "Please check for correct input JSON data."
stacktrace: "com.Snaplogic.api.ExecutionException:  ...
}


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.

Filter path



The Filter path property specifies the JSON path to the filter to be applied when parsing the given JSON data. The Snap extracts the parts of data that applies to the filter condition. For more information regarding JSON path, refer to the site http://goessner.net/articles/JsonPath/ 
Example: $.items.item.[?]
                $.items.item[?(@.price > 10)]
Default value: [None]
 

Non-standard JSON 


Required. The Non-standard JSON property specifies whether or not the Component should allow non-standard features in the given JSON data. 
Example: Selected 
Default value: Selected 


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 

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 value: Selected 


JSON lines

This property specifies the Snap's error handling when the input JSON data is newline-delimited JSON (JSON lines) and contains invalid JSON data:

If selected, the Snap writes an error and continues to parse the next JSON lines. The documents in a line after the invalid data are not parsed if the line contains more than one document. Lower performance is expected since the data is parsed one line at a time.
If not selected, the Snap writes an error and stops parsing. The Snap can parse JSON lines if each line has only one document. 

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.

Example: Selected 

Default value: Not selected 

Multiexcerpt include macro
nameSupport_Type_Extensions
pageJSON Formatter
Multiexcerpt include macro
nameME_Support_Type_Extensions
pageJSON Formatter

Multiexcerpt include macro
nameSnap Execution
pageAnaplan Read


Multiexcerpt include macro
nameSnap_Execution_Introduced
pageAnaplan Read


Info
titleInput as a non UTF-8 compliant

JSON Parser Snap supports reading the input file in UTF-8 format only. However, when the input data from the upstream is a non UTF-8 format (such as ISO-8859-13, IBM01144, windows-1258 and so on), use the Transcoder Snap to decode the format back to the UTF-8 compliant and then parse the data.

Examples

 
Expand
titleJSON Parser with JSON lines selected

JSON Parser with JSON Lines Selected

In the following pipeline, the JSON Parser Snap parses the valid lines from the upstream File Reader Snap and routes the invalid lines to the error view.


The File Reader passes four lines of which one line carries an invalid data with a missing delimiter:

The JSON Parser Snap parses the data from the upstream. Note the output preview displays the valid three lines only:

The invalid line is routed to the error view:


Expand
titleReading an input file other than the UTF-8 format

Reading an Input File Other Than the UTF-8 Format

Reading an input file other than the UTF-8 format:

The following pipeline reads the input file in ISO-8859-15 format to generate an output file in UTF-8 format.

Image Modified

The Transcoder Snap converts the incoming ISO-8859-15 format document into the UTF-8 compliant format.

The JSON Parser Snap parses the transcoded upstream document and displays the below output preview:

Image Modified



Expand
titleReading an upstream JSON file and Parsing the data

Reading an Upstream JSON File and Parsing the Data

If you have a JSON file that looks like this:

Image Modified

When it is read by a File Reader Snap, the output looks like this:

Image Modified

If you add a JSON Parser Snap after the File Read, the output then looks like this:

Image Modified


Insert excerpt
Transform Snap Pack
Transform Snap Pack
nopaneltrue