<< Outils web Outils web http_delete >>

Scilab Help >> Outils web > fromJSON

fromJSON

Convert JSON to a Scilab variable.

Syntax

result = fromJSON(jsonData)
result = fromJSON(jsonFilename, "file")

Arguments

jsonData
A string containing JSON data.

jsonFilename
A JSON file path.

result
If the string is a correct JSON, the result contains the Scilab variable.

Description

This function converts a string or a JSON file into a Scilab variable. NaN, Infinity and -Infinity are converted to %nan, %inf and -%inf. JSON null is converted to an empty matrix [] while it is converted to %nan in number arrays. Non-homogeneous data types or size arrays are converted into a list of elements.

Examples

// JSON object
fromJSON("{""status"": ""OK"", ""value"":12}")
// JSON array
fromJSON("[1, 2, 3]")
// JSON null values
fromJSON("[1, 2, null]")
fromJSON("[1, true, null]")
// non-finite values
fromJSON("[NaN, Infinity, -Infinity]")

See also

History

VersionDescription
6.1 Function introduced.
2023.0.0 Handling of tabs (ascii(9)) changed.
2024.1.0 NaN, -Infinity and Infinity values are now managed.

Report an issue
<< Outils web Outils web http_delete >>