Read JSON objects with Matlab

后端 未结 4 1850
死守一世寂寞
死守一世寂寞 2021-01-05 00:29

I want to read from a json file with Matlab and store everything in \"data\" as objects. After import, I need to iterate through all and extract specific values, if it\'s av

4条回答
  •  别那么骄傲
    2021-01-05 01:12

    If your file is accessible via http or https, you can use the webread function from the Data Import and Export toolbox. It automatically converts JSON files to Matlab structures.

    There is a decodeJSON function in the toolbox (MATLABROOT/toolbox/matlab/external/interfaces/webservices/restful/private/decodeJSON.m), but the help clearly states that:

    % FOR INTERNAL USE ONLY -- This function is intentionally undocumented
    %   and is intended for use only within the scope of functions and classes
    %   in toolbox/matlab/external/interfaces/webservices/restful. Its behavior
    %   may change, or the class itself may be removed in a future release.
    

    Nevertheless you can get inspiration in the content to build your own solution. It's a pity that the Mathworks didn't made this program available outside the toolbox.

    Best

提交回复
热议问题