Matlab JSON


https://github.com/kyamagu/matlab-json/
Matlab JSON v0.2


This package contains Matlab class to serialize/decode matlab object in json format. The software uses org.json java package to convert json to java object and then translates it into Matlab object.
API


All functions are scoped under json namespace.
startup Initialize runtime environment.
dump Encode matlab value into a JSON string.
load Load matlab value from a JSON string.
read Load a matlab value from a JSON file.
write Write a matlab value into a JSON file.

Usage


Add path to the directory containing +json before use, and call json.startup.
>> addpath /path/to/matlab-json
>> json.startup
To serialize matlab object:
>> X = struct('field1', magic(2), 'field2', 'hello');
>> S = json.dump(X);
>> disp(S);
{"field2":"hello","field1":[[1,3],[4,2]]}
To decode json string:
>> X = json.load(S);
>> disp(X);
 field2: 'hello' 
 field1: [2x2 double]
To read from or write to a json file.
>> json.write(X, '/path/to/file.json');
>> X = json.read('/path/to/file.json');

留言

這個網誌中的熱門文章

網路筆記 File Upload on PHP Server in Android

LA流浪記

杜拜