Table Of Contents

Unflatten from JSON (G Dataflow)

Last Modified: December 18, 2017

Converts a UTF-8 JavaScript Object Notation (JSON) string to another data type.

connector_pane_image
datatype_icon

enable LabVIEW extensions

A Boolean that determines whether JSON extensions support NaN and Inf values of floating-point numbers. Not all JSON parsers support these extensions.

True Enable JSON extension support of NaN and Inf values of floating-point numbers.
False Disable JSON extension support of NaN and Inf values of floating-point numbers.

Default: True

datatype_icon

path

A specific item in the JSON string. Use path if your JSON string contains multiple items and you would like to extract a specific item from it. path uses an array of strings to identify the item, where each element in the array references either the name of a cluster element or an integer index of an array. If you specify an item using path, you must wire a data type to type and defaults that corresponds to the data type of the specified item.

Type/Default Inputs and Corresponding Outputs

Consider the JSON string {"0":"abc","1":false,"2":[9,8,7]}. The following table illustrates an example of type/defaults inputs required for various paths and the resulting value outputs.

Path Type and Defaults Value Comments
If path is empty, type and defaults must account for each element in the JSON string. You must wire a cluster containing a string, a Boolean, and an array to type and defaults.
In this example, the path points to the cluster element named 0, or string abc. You must wire a string to type and defaults.
In this example, the path points to the cluster element named 2, which is an array, and the element at index 0 of that array. This element is a floating-point number, so you must wire a DBL numeric to type and defaults.
datatype_icon

JSON string

The flattened UTF-8 string that you want to unflatten.

datatype_icon

type and defaults

The data type and default values to which you want to unflatten the JSON string. This input accepts Booleans, integers, floating-point numbers, strings, and arrays or clusters of these types. Cluster elements may be labeled or unlabeled, but not a combination of both. If elements in a cluster are labeled, then each name must be unique to that cluster. If elements in your JSON string are labeled, the elements wired to type and defaults must have an identical label. For example, if you have JSON string {"firstelement":"a","secondelement":"b"}, you must wire a cluster containing a string labeled firstelement and a string labeled secondelement. Additionally, if you specify the path to a particular item in your JSON string, the data type wired to type and defaults must match the data type of the item pointed to by path.

datatype_icon

error in

Error conditions that occur before this node runs.

The node responds to this input according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Default: No error

datatype_icon

default null elements?

A Boolean that determines how null values in JSON string are processed.

True Uses default values from the input cluster for null values in JSON string.
False Returns an error for null values.

Default: False

datatype_icon

strict validation?

A Boolean that determines whether to return an error when JSON string contains items not defined in type and defaults.

True Returns an error when JSON string contains items not defined in type and defaults.
False The JSON object may contain items not defined in type and defaults.

Default: False

datatype_icon

value

Unflattened data of the same data type and structure as type and defaults.

datatype_icon

error out

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Converting Data Types not Supported by Type and Defaults

If JSON string represents a data type that type/defaults does not accept, such as an array of arrays or an array of mixed types, you cannot use a single Unflatten From JSON node to convert the entire JSON string. However, you can use path to identify and extract items in the JSON string.

Where This Node Can Run:

Desktop OS: Windows

FPGA: This product does not support FPGA devices

Web Server: Supported in VIs that run in a web application


Recently Viewed Topics