Rank: 472 based on 175 downloads (last 30 days) and 1 file submitted
photo

Qianqian Fang

E-mail
Company/University
Harvard University

Personal Profile:
Professional Interests:
EM modeling, medical imaging

 

Watch this Author's files

 

Files Posted by Qianqian
Updated   File Tags Downloads
(last 30 days)
Comments Rating
20 Jun 2012 Screenshot JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave JSONlab is an open-source implementation of a JSON encoder and a decoder/parser for MATLAB/Octave. Author: Qianqian Fang decoder, xml, matlab, octave, json, parser 175 37
  • 4.55556
4.6 | 9 ratings
Comments and Ratings by Qianqian View all
Updated File Comments Rating
06 Sep 2012 JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave JSONlab is an open-source implementation of a JSON encoder and a decoder/parser for MATLAB/Octave. Author: Qianqian Fang

hi Chuck37

the issue you had reported is related to the cell2mat call on line#248 of loadjson. you can compare the following:

a=struct('one',1,'two',2);
b=[a a];
c={a,a};
class(b)
class(c)
class(cell2mat(c))

in many other cases, this kind of conversion is beneficial because it simplifies the data by looking into the internal regularity. However, it does come with the side-effect you have described.

To solve this issue, I just committed SVN#384, accepting a flag to control cell array->struct array conversion, see

http://iso2mesh.svn.sourceforge.net/viewvc/iso2mesh?view=revision&revision=384

you may check out this version and run the following to compare:

d=loadjson(savejson('',c))
class(d)
d=loadjson(savejson('',c),'SimplifyCell',1)
class(d)

by default, loadjson no longer converts a cell array to a struct array.

06 Sep 2012 JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave JSONlab is an open-source implementation of a JSON encoder and a decoder/parser for MATLAB/Octave. Author: Qianqian Fang

@Arnout: 2D cell is currently not supported by jsonlab. I hope this can be added in the future versions. Contribution on this is welcome!

20 Jun 2012 JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave JSONlab is an open-source implementation of a JSON encoder and a decoder/parser for MATLAB/Octave. Author: Qianqian Fang

hi Mark

I just uploaded a new JSONLAB release, v0.9.0. Aside from various bug fixes, one of the main features of this release is the better round-trip consistency you suggested earlier. A leading underscore is now converted to x0x5F_; all hex codes generated by loadjson are automatically converted back to string forms in savejson.

A remaining issue is the handling of multi-byte characters in matlab. If this is the case, you may have to run feature('DefaultCharacterSet','latin1') in matlab to get consistent results.

Let me know if you are happy with this new release. (download from http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab/Download )

06 Jun 2012 JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave JSONlab is an open-source implementation of a JSON encoder and a decoder/parser for MATLAB/Octave. Author: Qianqian Fang

hi Mark

taking out the try-catch block can give you very verbose output. For a simple array input, the output becomes a cell array with each element a cell. It becomes very difficult to read and process.

I think the difficulty we are facing comes from the ambiguity when mapping a matlab data structures to JSON. For example, when you say "foo", you can map it to "foo", {"foo"} or ["foo"], or even {["foo"]}. I chose the simplest one for now, because I don't know what we would gain from having the brackets (differentiate from an array origin or a cell origin?)

For the underscores, a unique prefix/suffix seems to be the safe way to go. If I were to implement this feature, I would add something like JSONLAB_LEADING_UNDERSCORE_ to both loadjson/savejson, and use opt.LeadingUnderscore as an input option.

30 May 2012 JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave JSONlab is an open-source implementation of a JSON encoder and a decoder/parser for MATLAB/Octave. Author: Qianqian Fang

hi Mark

regarding your first question, no, the NoRowBracket only applies to "numerical elements". I don't see any problems for processing array of strings though.

For your second question, it is not difficult for me to add a non-standard option to do the conversion. However, the current approach to deal with a leading underscore is to prepend an "x", similar to the behavior of MATLAB function genvarname(). However, once converted, a name in the form of "x_..." becomes difficult to separate from the genuine ones. A conversion from "x_..." to "_..." may have false positives. I am not sure if this is the best way to do, unless I define a unique prefix in the loadjson for this scenario.

Comments and Ratings on Qianqian's Files View all
Updated File Comment by Comments Rating
19 Feb 2013 JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave JSONlab is an open-source implementation of a JSON encoder and a decoder/parser for MATLAB/Octave. Author: Qianqian Fang Mikofski, Mark

@Jan, I've been using a JSON.jar [1] I made from the java-json source [2] and it works perfectly. I don't know how native java speed compares with native MATLAB though.

[1] http://dl.dropbox.com/u/19049582/JSON.jar
[2] http://json.org/java/

19 Feb 2013 JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave JSONlab is an open-source implementation of a JSON encoder and a decoder/parser for MATLAB/Octave. Author: Qianqian Fang Leah

I would have liked if there was an option to return as a dataset. Added these lines

data=data.data;
data=struct2cell(data);
data=cell2mat(squeeze(data)');
data= dataset({data(:,1), 'TimeEPOC'}, {data(:,2), 'Value'});

28 Jan 2013 JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave JSONlab is an open-source implementation of a JSON encoder and a decoder/parser for MATLAB/Octave. Author: Qianqian Fang Klapuri, Anssi

Correction to my previous post: The mentioned line should read "currstr=inStr(pos:min(pos+100,end));" of course.

28 Jan 2013 JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave JSONlab is an open-source implementation of a JSON encoder and a decoder/parser for MATLAB/Octave. Author: Qianqian Fang Klapuri, Anssi

Excellent contribution. For large json files (mine was >100MB), you can make the code >100 times faster by replacing the line "currstr=inStr(pos:end);" with "currstr=inStr(pos:pos+100);" in parse_number().

08 Oct 2012 JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave JSONlab is an open-source implementation of a JSON encoder and a decoder/parser for MATLAB/Octave. Author: Qianqian Fang Reinert Nash, John

Useful, fast parser. Much appreciated!

Top Tags Applied by Qianqian
decoder, encoder, html, json, jsonlab
Files Tagged by Qianqian
Updated   File Tags Downloads
(last 30 days)
Comments Rating
20 Jun 2012 Screenshot JSONlab: a toolbox to encode/decode JSON files in MATLAB/Octave JSONlab is an open-source implementation of a JSON encoder and a decoder/parser for MATLAB/Octave. Author: Qianqian Fang decoder, xml, matlab, octave, json, parser 175 37
  • 4.55556
4.6 | 9 ratings

Contact us