Owning Palette: Flatten/Unflatten String Functions
Requires: Base Development System
Converts a UTF-8 JavaScript Object Notation (JSON) string to the LabVIEW data type you wire to type/defaults.
Add to the block diagram | Find on the palette |
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.
|
|||||||||||||||||
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. |