Code covered by the BSD License  

Highlights from
JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave

image thumbnail

JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave

by

 

19 Oct 2011 (Updated )

JSONlab is an open-source JSON/UBJSON encoder and decoder (parser) for MATLAB and Octave.

jsonlab_selftest.m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%         Regression Test Unit of loadjson and savejson
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

for i=1:4
    fname=sprintf('example%d.json',i);
    if(exist(fname,'file')==0) break; end
    fprintf(1,'===============================================\n>> %s\n',fname);
    json=savejson('data',loadjson(fname));
    fprintf(1,'%s\n',json);
    data=loadjson(json);
end

for i=1:4
    fname=sprintf('example%d.json',i);
    if(exist(fname,'file')==0) break; end
    fprintf(1,'===============================================\n>> %s\n',fname);
    json=saveubjson('data',loadjson(fname));
    fprintf(1,'%s\n',json);
    data=loadubjson(json);
    savejson('',data)
end

Contact us