jsondecode
decodes a JSON string to Nelson object.
📝Syntax
res = jsondecode(json_str)
res = jsondecode(json_str, '-file')
📥Input Arguments
Parameter Description
json_str a json string.
'-file' a string, first argument is the file path.
📤Output Arguments
Parameter Description
res a nelson variable converted from JSON.
📄Description

jsondecode converts JSON object field names to Nelson structure field names

💡Examples
field1 = 'f1';  value1 = zeros(1,10);
field2 = 'f2';  value2 = {'a', 'b'};
field3 = 'f3';  value3 = {pi, pi*pi};
field4 = 'f4';  value4 = {'fourth'};
s = struct(field1,value1,field2,value2,field3,value3,field4,value4)
r = jsonencode(s)
r2 = jsondecode(r)
jsondecode([modulepath('json'), '/examples/patient.json'], '-file')
    
🔗See Also
jsonencodefileread
📚Bibliography
http://www.rfc-editor.org/rfc/rfc7159.txt
🕔Version History
Version Description
1.0.0 initial version
1.15.0 second argument added for file input
1.15.0 simdjson library used
Edit this page on GitHub