Skip to content

jsondecode

builtin · libnexusinterp/corefcn/jsondecode-proprietary.cc

: obj = jsondecode (text)
: obj = jsondecode (text, name, value, …)

Convert the JSON document text into a Nexus value.

JSON numbers become doubles, true and false become logical values, strings become character rows and objects become scalar structures whose fields follow the order of the document. null gives an empty matrix, or NaN when it sits inside an array of numbers.

An array of numbers is returned as a column vector, an array of booleans as a logical column. Arrays of equally long arrays of numbers (or booleans) become matrices and, with deeper nesting, N-dimensional arrays, with x(i,j,k) holding the element json[i][j][k]. An array of objects with identical members becomes a structure array. Any other array becomes a column cell array of its individually converted elements.

Member names are turned into valid field names the way matlab.lang.makeValidName does. The options are "ReplacementStyle" ("underscore", "delete" or "hex"), "Prefix" (default "x") and "makeValidName" (a logical, default true; false keeps the names as written). Option names are not case sensitive.