Unflatten from JSON

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

1378

Inputs/Outputs

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 value: 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
1378 1378 1378 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.

1378

1378 1378 In this example, the path points to the cluster element named 0, or string abc. You must wire a string to type and defaults.

1378

1378 1378 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

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

Converting Data Types not Supported by Type and Defaults

Unflatten From JSON