Monday 15 June 2015

Fast JSON Parser for Matlab -



Fast JSON Parser for Matlab -

do know fast json parser matlab?

currently i'm using jsonlab, larger json files (mine 12 mb, 500 000 lines) it's slow. or have tips' me increment speed?

p.s. json file max. 3 levels deep.

if want fast, utilize java json parser. , before reply gets out of hand, going post stuff set downwards far:

clc % input illustration jsonstr = '{"bool1": true, "string1": "some text", "double1": 5, "array1": [1,2,3], "nested": {"val1": 1, "val2": "one"}}' % utilize java.. javaaddpath('json.jar'); jsonobj = org.json.jsonobject(jsonstr); % check out available methods jsonobj.methods % see http://www.json.org/javadoc/org/json/jsonobject.html % stuff b = jsonobj.getboolean('bool1') s = jsonobj.getstring('string1') d = jsonobj.getdouble('double1') = jsonobj.getjsonobject('nested').getint('val1') % set stuff jsonobj = jsonobj.put('sum', 1+1); % getting array or matrix not easy (you jsonarray) e = jsonobj.get('array1'); % methods access jsonarray? e.methods idx = 1:e.length() e.get(idx-1) end % putting arrays or matrices works fine jsonobj = jsonobj.put('matrix1', ones(5)); % can these .. m1 = jsonobj.get('matrix1') % .. long dont convert obj string jsonobj = org.json.jsonobject(jsonobj.tostring()); m2 = jsonobj.get('matrix1')

json matlab parsing

No comments:

Post a Comment