File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 181181 tempobj.attr = obj .attr ;
182182 tempobj.currentpath = trackpath ;
183183 val = v(tempobj , idxkey(i + 1 ));
184- elseif (isa(val , ' jdict' ))
184+ elseif (isa(val , ' jdict' ))
185185 val = val .data ;
186186 end
187187 else
Original file line number Diff line number Diff line change 11function jsonstr = yaml2json(yamlstr )
22% Convert YAML to JSON
3+ %
4+ % jsonstr = yaml2json(yamlstr)
5+ %
6+ % Convert a YAML string to JSON format for parsing with loadjson
7+ %
8+ % input:
9+ % yamlstr: a YAML string
10+ %
11+ % output:
12+ % jsonstr: a JSON string
13+ %
14+ % examples:
15+ % jsonstr = yaml2json('name: value')
16+ % jsonstr = yaml2json(sprintf('- a\n- b\n- c'))
17+ %
18+ % license:
19+ % BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details
20+ %
21+ % -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
22+ %
323
424lines = regexp(yamlstr , ' \s*\r *\n ' , ' split' );
525
3757 continue
3858 end
3959
60+ % Check if entire line is a JSON literal (array or object)
61+ if (trimmed(1 ) == ' [' || trimmed(1 ) == ' {' )
62+ jsonstr = trimmed ;
63+ return
64+ end
65+
4066 indent = length(line ) - length(trimmed );
4167 islist = length(trimmed ) >= 2 && strcmp(trimmed(1 : 2 ), ' - ' );
4268
You can’t perform that action at this time.
0 commit comments