|
107 | 107 | else
|
108 | 108 | string = urlread(fname);
|
109 | 109 | end
|
110 |
| -elseif (~isempty(fname) && any(fname(1) == '[{SCHiUIulmLMhdDTFZN')) |
| 110 | +elseif (~isempty(fname) && any(fname(1) == '[{SCBHiUIulmLMhdDTFZN')) |
111 | 111 | string = fname;
|
112 | 112 | else
|
113 | 113 | error('input file does not exist or buffer is invalid');
|
|
166 | 166 | else
|
167 | 167 | [data{jsoncount}, pos] = parse_array(inputstr, pos, opt);
|
168 | 168 | end
|
169 |
| - case {'S', 'C', 'H', 'i', 'U', 'I', 'u', 'l', 'm', 'L', 'M', 'h', 'd', 'D', 'T', 'F', 'Z', 'N'} |
| 169 | + case {'S', 'C', 'B', 'H', 'i', 'U', 'I', 'u', 'l', 'm', 'L', 'M', 'h', 'd', 'D', 'T', 'F', 'Z', 'N'} |
170 | 170 | [data{jsoncount}, pos] = parse_value(inputstr, pos, [], opt);
|
171 | 171 | otherwise
|
172 |
| - error_pos('Root level structure must start with a valid marker "{[SCHiUIulmLMhdDTFZN"', inputstr, pos); |
| 172 | + error_pos('Root level structure must start with a valid marker "{[SCBHiUIulmLMhdDTFZN"', inputstr, pos); |
173 | 173 | end
|
174 | 174 | if (jsoncount >= maxobjid)
|
175 | 175 | break
|
|
219 | 219 | [data{i}, pos] = parse_value(inputstr, pos, type, varargin{:});
|
220 | 220 | end
|
221 | 221 | adv = pos - adv;
|
222 |
| - case 'C' |
223 |
| - data = inputstr(pos:pos + count); |
| 222 | + case {'C', 'B'} |
| 223 | + data = inputstr(pos:pos + count - 1); |
224 | 224 | adv = count;
|
225 | 225 | case {'T', 'F', 'N'}
|
226 | 226 | error_pos(sprintf('For security reasons, optimized type %c is disabled at position %%d', type), inputstr, pos);
|
|
378 | 378 | function [str, pos] = parseStr(inputstr, pos, type, varargin)
|
379 | 379 | if (isempty(type))
|
380 | 380 | type = inputstr(pos);
|
381 |
| - if type ~= 'S' && type ~= 'C' && type ~= 'H' |
| 381 | + if type ~= 'S' && type ~= 'C' && type ~= 'B' && type ~= 'H' |
382 | 382 | error_pos('String starting with S expected at position %d', inputstr, pos);
|
383 | 383 | else
|
384 | 384 | pos = pos + 1;
|
385 | 385 | end
|
386 | 386 | end
|
387 | 387 |
|
388 |
| -if (type == 'C') |
| 388 | +if (type == 'C' || type == 'B') |
389 | 389 | str = inputstr(pos);
|
390 | 390 | pos = pos + 1;
|
391 | 391 | return
|
|
432 | 432 | varargout{3} = {};
|
433 | 433 | end
|
434 | 434 | switch (cc)
|
435 |
| - case {'S', 'C', 'H'} |
| 435 | + case {'S', 'C', 'B', 'H'} |
436 | 436 | [varargout{1:2}] = parseStr(inputstr, varargout{2}, type, varargin{:});
|
437 | 437 | return
|
438 | 438 | case '['
|
|
488 | 488 | object = [];
|
489 | 489 | end
|
490 | 490 | count = -1;
|
| 491 | +type = []; |
491 | 492 | [cc, pos] = next_char(inputstr, pos);
|
492 | 493 | if (cc == '$')
|
| 494 | + type = inputstr(pos + 1); |
493 | 495 | pos = pos + 2;
|
494 | 496 | end
|
495 | 497 | [cc, pos] = next_char(inputstr, pos);
|
|
522 | 524 | mmap{end}{2} = [mmap{end}{2}, pos - mmap{end}{2}];
|
523 | 525 | mmap = [mmap(:); newmmap(:)];
|
524 | 526 | else
|
525 |
| - [val, pos] = parse_value(inputstr, pos, [], varargin{:}); |
| 527 | + [val, pos] = parse_value(inputstr, pos, type, varargin{:}); |
526 | 528 | end
|
527 | 529 | num = num + 1;
|
528 | 530 | if (usemap)
|
|
537 | 539 | object.(str) = val;
|
538 | 540 | end
|
539 | 541 | [cc, pos] = next_char(inputstr, pos);
|
540 |
| - if (count >= 0 && num >= count) || cc == '}' |
| 542 | + if ((count >= 0 && num >= count) || (~isempty(cc) && cc == '}')) |
541 | 543 | break
|
542 | 544 | end
|
543 | 545 | end
|
|
0 commit comments