Skip to content

Commit e06b156

Browse files
committed
[ci] fix octave ci error
1 parent f03d082 commit e06b156

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

jdict.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
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

yaml2json.m

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
function 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

424
lines = regexp(yamlstr, '\s*\r*\n', 'split');
525

@@ -37,6 +57,12 @@
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

0 commit comments

Comments
 (0)