Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Unflatten From JSON Function

LabVIEW 2013 Help

Edition Date: June 2013

Part Number: 371361K-01

»View Product Info

Owning Palette: Flatten/Unflatten String Functions

Requires: Base Development System

Converts a UTF-8 JSON string to the LabVIEW data type you wire to type/defaults.

enable LabVIEW extensions enables LabVIEW JSON extensions to support NaN and Inf values of floating-point numbers. Not all JSON parsers support these extensions.
path identifies a specific item in 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/defaults that corresponds to the data type of the specified item. For example, consider the JSON string {"0":"abc","1":false,"2":[9,8,7]}. The following table illustrates the type/defaults inputs required for various paths and the resulting value outputs.

path type/defaults value Comments
type/defaults A cluster containing string abc, Boolean FALSE, and array [9,8,7] If path is empty, type/defaults must account for each element in the JSON string. For the example JSON string, you must wire a cluster containing a string, a Boolean, and an array to type/defaults.
type/defaults String abc In this example, the path points to the cluster element named 0, or string abc. Therefore, you must wire a string to type/defaults.
type/defaults DBL numeric 9 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 a DBL numeric must be wired to type/defaults.
JSON string is the flattened UTF-8 string that you want to unflatten. You can use the Flatten To JSON function to generate this string.
type/defaults specifies 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 the elements in a cluster are labeled, then each name must be unique to that cluster. If you wire an unsupported data type, LabVIEW breaks the VI.

If the elements in your JSON string are labeled, the elements wired to types/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/defaults must match the data type of the item pointed to by path.
error in describes error conditions that occur before this node runs. This input provides standard error in functionality.
default null elements specifies whether LabVIEW uses default values from the input cluster for null values in JSON. If default null elements is FALSE, LabVIEW returns an error for null values.
strict validation determines whether LabVIEW returns an error when the JSON object contains items not defined in the input cluster. If strict validation is FALSE, JSON objects may contain items not defined in the cluster.
value returns JSON string as unflattened data of the same data type and structure as type/defaults.
error out contains error information. This output provides standard error out functionality.


Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit