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
- http_post — HTTP POST request.
- http_put — HTTP PUT request.
- http_patch — HTTP PATCH request.
- http_delete — HTTP DELETE request.
- http_upload — HTTP POST or PUT request to upload file(s) on server.
- toJSON — Convert a Scilab variable to a JSON string.
- http_get — HTTP GET request.
History
Version | Description |
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 >> |