|
230 | 230 | % JDataDecode [1|0]: if set to 1, call jdatadecode to decode
|
231 | 231 | % JData structures defined in the JData
|
232 | 232 | % Specification.
|
| 233 | +% BuiltinJSON [0|1]: if set to 1, this function attempts to call |
| 234 | +% jsondecode, if presents (MATLAB R2016b or Octave |
| 235 | +% 6) first. If jsondecode does not exist or failed, |
| 236 | +% this function falls back to the jsonlab parser |
233 | 237 | %
|
234 | 238 | % output:
|
235 | 239 | % dat: a cell array, where {...} blocks are converted into cell arrays,
|
|
347 | 351 | % 'b': big endian, 'l': little-endian)
|
348 | 352 | % PreEncode [1|0]: if set to 1, call jdataencode first to preprocess
|
349 | 353 | % the input data before saving
|
| 354 | +% BuiltinJSON [0|1]: if set to 1, this function attempts to call |
| 355 | +% jsonencode, if presents (MATLAB R2016b or Octave |
| 356 | +% 6) first. If jsonencode does not exist or failed, |
| 357 | +% this function falls back to the jsonlab savejson |
350 | 358 | %
|
351 | 359 | % opt can be replaced by a list of ('param',value) pairs. The param
|
352 | 360 | % string is equivallent to a field in opt and is case sensitive.
|
|
375 | 383 | % or
|
376 | 384 | % data=loadbj(fname,'param1',value1,'param2',value2,...)
|
377 | 385 | %
|
378 |
| -% Parse a Binary JData (BJData v1 Draft-1, defined in https://github.com/OpenJData/bjdata) |
| 386 | +% Parse a Binary JData (BJData v1 Draft-2, defined in https://github.com/NeuroJSON/bjdata) |
379 | 387 | % file or memory buffer and convert into a MATLAB data structure
|
380 | 388 | %
|
| 389 | +% By default, this function parses BJD-compliant output. The BJD |
| 390 | +% specification is largely similar to UBJSON, with additional data types |
| 391 | +% including uint16(u), uint32(m), uint64(M) and half-precision float (h). |
| 392 | +% Starting from BJD Draft-2 (JSONLab 3.0 beta or later), all integer and |
| 393 | +% floating-point numbers are parsed in Little-Endian as opposed to |
| 394 | +% Big-Endian form as in BJD Draft-1/UBJSON Draft-12 (JSONLab 2.1 or older) |
| 395 | +% |
381 | 396 | % initially created on 2013/08/01
|
382 | 397 | %
|
383 | 398 | % input:
|
|
391 | 406 | % SimplifyCell [1|0]: if set to 1, loadbj will call cell2mat
|
392 | 407 | % for each element of the JSON data, and group
|
393 | 408 | % arrays based on the cell2mat rules.
|
394 |
| -% IntEndian [B|L]: specify the endianness of the integer fields |
395 |
| -% in the BJData/UBJSON input data. B - Big-Endian format for |
396 |
| -% integers (as required in the UBJSON specification); |
397 |
| -% L - input integer fields are in Little-Endian order. |
| 409 | +% Endian ['L'|'B']: specify the endianness of the numbers |
| 410 | +% in the BJData/UBJSON input data. Default: 'L'. |
| 411 | +% |
| 412 | +% Starting from JSONLab 2.9, BJData by default uses |
| 413 | +% [L] Little-Endian for both integers and floating |
| 414 | +% point numbers. This is a major departure from the |
| 415 | +% UBJSON specification, where 'B' - Big-Endian - |
| 416 | +% format is used for integer fields. UBJSON does |
| 417 | +% not specifically define Endianness for |
| 418 | +% floating-point numbers, resulting in mixed |
| 419 | +% implementations. JSONLab 2.0-2.1 used 'B' for |
| 420 | +% integers and floating-points; JSONLab 1.x uses |
| 421 | +% 'B' for integers and native-endianness for |
| 422 | +% floating-point numbers. |
398 | 423 | % NameIsString [0|1]: for UBJSON Specification Draft 8 or
|
399 | 424 | % earlier versions (JSONLab 1.0 final or earlier),
|
400 | 425 | % the "name" tag is treated as a string. To load
|
401 | 426 | % these UBJSON data, you need to manually set this
|
402 | 427 | % flag to 1.
|
403 |
| -% UseMap [0|1]: if set to 1, loadjson uses a containers.Map to |
| 428 | +% UseMap [0|1]: if set to 1, loadbj uses a containers.Map to |
404 | 429 | % store map objects; otherwise use a struct object
|
405 | 430 | % ObjectID [0|interger or list]: if set to a positive number,
|
406 | 431 | % it returns the specified JSON object by index
|
|
436 | 461 | % bjd=savebj(rootname,obj,'param1',value1,'param2',value2,...)
|
437 | 462 | %
|
438 | 463 | % Convert a MATLAB object (cell, struct, array, table, map, handles ...)
|
439 |
| -% into a Binary JData (BJData v1 Draft-1), Universal Binary JSON (UBJSON, |
| 464 | +% into a Binary JData (BJData v1 Draft-2), Universal Binary JSON (UBJSON, |
440 | 465 | % Draft-12) or a MessagePack binary stream
|
441 | 466 | %
|
442 | 467 | % initially created on 2013/08/17
|
443 | 468 | %
|
444 | 469 | % By default, this function creates BJD-compliant output. The BJD
|
445 | 470 | % specification is largely similar to UBJSON, with additional data types
|
446 |
| -% including uint16(u), uint32(m), uint64(M) and half-precision float (h) |
| 471 | +% including uint16(u), uint32(m), uint64(M) and half-precision float (h). |
| 472 | +% Starting from BJD Draft-2 (JSONLab 3.0 beta or later), all integer and |
| 473 | +% floating-point numbers are stored in Little-Endian as opposed to |
| 474 | +% Big-Endian form as in BJD Draft-1/UBJSON Draft-12 (JSONLab 2.1 or older) |
447 | 475 | %
|
448 | 476 | % Format specifications:
|
449 |
| -% Binary JData (BJD): https://github.com/fangq/bjdata |
| 477 | +% Binary JData (BJD): https://github.com/NeuroJSON/bjdata |
450 | 478 | % UBJSON: https://github.com/ubjson/universal-binary-json
|
451 | 479 | % MessagePack: https://github.com/msgpack/msgpack
|
452 | 480 | %
|
|
524 | 552 | % UBJSON [0|1]: 0: (default)-encode data based on BJData Draft 1
|
525 | 553 | % (supports uint16(u)/uint32(m)/uint64(M)/half(h) markers)
|
526 | 554 | % 1: encode data based on UBJSON Draft 12 (without
|
527 |
| -% u/m/M/h markers) |
| 555 | +% u/m/M/h markers);all numeric values are stored in |
| 556 | +% the Big-Endian byte order according to Draft-12 |
528 | 557 | % FormatVersion [2|float]: set the JSONLab output version; since
|
529 | 558 | % v2.0, JSONLab uses JData specification Draft 3
|
530 | 559 | % for output format, it is incompatible with releases
|
|
535 | 564 | % of the minimum length without losing accuracy (default)
|
536 | 565 | % Debug [0|1]: output binary numbers in <%g> format for debugging
|
537 | 566 | % Append [0|1]: if set to 1, append a new object at the end of the file.
|
538 |
| -% Endian ['n'|'b','l']: Endianness of the output file ('n': native, |
| 567 | +% Endian ['L'|'B']: specify the endianness of the numbers |
| 568 | +% in the BJData/UBJSON input data. Default: 'L'. |
| 569 | +% |
| 570 | +% Starting from JSONLab 2.9, BJData by default uses |
| 571 | +% [L] Little-Endian for both integers and floating |
| 572 | +% point numbers. This is a major departure from the |
| 573 | +% UBJSON specification, where 'B' - Big-Endian - |
| 574 | +% format is used for integer fields. UBJSON does |
| 575 | +% not specifically define Endianness for |
| 576 | +% floating-point numbers, resulting in mixed |
| 577 | +% implementations. JSONLab 2.0-2.1 used 'B' for |
| 578 | +% integers and floating-points; JSONLab 1.x uses |
| 579 | +% 'B' for integers and native-endianness for |
| 580 | +% floating-point numbers. |
| 581 | +% FileEndian ['n'|'b','l']: Endianness of the output file ('n': native, |
539 | 582 | % 'b': big endian, 'l': little-endian)
|
540 | 583 | % PreEncode [1|0]: if set to 1, call jdataencode first to preprocess
|
541 | 584 | % the input data before saving
|
|
553 | 596 | % 'MeshCreator','FangQ','MeshTitle','T6 Cube',...
|
554 | 597 | % 'SpecialData',[nan, inf, -inf]);
|
555 | 598 | % savebj(jsonmesh)
|
| 599 | +% savebj('',jsonmesh,'debug',1) |
556 | 600 | % savebj('',jsonmesh,'meshdata.bjd')
|
557 | 601 | % savebj('mesh1',jsonmesh,'FileName','meshdata.msgpk','MessagePack',1)
|
558 | 602 | % savebj('',jsonmesh,'ubjson',1)
|
|
576 | 620 | % This function is an alias to loadbj
|
577 | 621 | %
|
578 | 622 | % input:
|
579 |
| -% fname: input file name, if fname contains "{}" or "[]", fname |
580 |
| -% will be interpreted as a UBJSON string |
| 623 | +% fname: input file name, if the file with such name exists, it will |
| 624 | +% be read, otherwise, this function will attempt to parse the |
| 625 | +% string in fname as a UBJSON stream |
581 | 626 | % opt: a struct to store parsing options, opt can be replaced by
|
582 | 627 | % a list of ('param',value) pairs - the param string is equivallent
|
583 | 628 | % to a field in opt. The supported options can be found by typing
|
|
606 | 651 | % ubj=saveubjson(rootname,obj,opt)
|
607 | 652 | % ubj=saveubjson(rootname,obj,'param1',value1,'param2',value2,...)
|
608 | 653 | %
|
609 |
| -% Convert a MATLAB object (cell, struct, array, table, map, handles ...) |
610 |
| -% into a Universal Binary JSON (UBJSON, Draft 12) or a MessagePack binary stream |
| 654 | +% Convert a MATLAB object (cell, struct, array, table, map, graphs ...) |
| 655 | +% into a Universal Binary JSON (UBJSON, Draft-12) or a MessagePack binary stream |
611 | 656 | %
|
612 | 657 | % initially created on 2013/08/17
|
613 | 658 | %
|
614 | 659 | % Format specifications:
|
615 |
| -% Binary JData (BJData):https://github.com/fangq/bjdata |
| 660 | +% Binary JData (BJData):https://github.com/NeuroJSON/bjdata |
616 | 661 | % UBJSON: https://github.com/ubjson/universal-binary-json
|
617 | 662 | % MessagePack: https://github.com/msgpack/msgpack
|
618 | 663 | %
|
619 |
| -% This function is the same as calling "savebj(...,'ubjson',1)". By , |
620 |
| -% default this function creates UBJSON-compliant output without the |
| 664 | +% This function is the same as calling "savebj(..,'ubjson',1,'endian','B')" |
| 665 | +% By default this function creates UBJSON-compliant output without the |
621 | 666 | % newly added uint16(u), uint32(m), uint64(M) and half-precision float (h)
|
622 |
| -% data types. |
| 667 | +% data types and use Big-Endian for all numerical values as in UBJSON |
| 668 | +% Draft-12. |
623 | 669 | %
|
624 | 670 | % This function by default still enables an optimized ND-array format for efficient
|
625 | 671 | % array storage. To ensure the output compatible to UBJSON Draft-12, one should use
|
|
641 | 687 | % Please type "help savebj" for details for all supported options.
|
642 | 688 | %
|
643 | 689 | % output:
|
644 |
| -% json: a binary string in the UBJSON format (see http://ubjson.org) |
| 690 | +% ubj: a binary string in the UBJSON format (see http://ubjson.org) |
645 | 691 | %
|
646 | 692 | % examples:
|
647 | 693 | % jsonmesh=struct('MeshVertex3',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],...
|
|
720 | 766 | % fname: (optional) output file name; if not given, save to 'jamdata.jamm'
|
721 | 767 | % if fname has a '.json' or '.jdt' suffix, a text-based
|
722 | 768 | % JSON/JData file will be created (slow); if the suffix is '.jamm' or
|
723 |
| -% '.jdb', a Binary JData (https://github.com/fangq/bjdata/) file will be created. |
| 769 | +% '.jdb', a Binary JData (https://github.com/NeuroJSON/bjdata/) file will be created. |
724 | 770 | % opt: (optional) a struct to store parsing options, opt can be replaced by
|
725 | 771 | % a list of ('param',value) pairs - the param string is equivallent
|
726 | 772 | % to a field in opt. opt can have the following
|
|
780 | 826 | % parse the json file and then decode the output by
|
781 | 827 | % jdatadecode; input file must have a suffix of .jdt
|
782 | 828 | %
|
783 |
| -% all options for loadubjson/loadjson (depends on file suffix) |
| 829 | +% all options for loadbj/loadjson (depends on file suffix) |
784 | 830 | % can be used to adjust the parsing options
|
785 | 831 | %
|
786 | 832 | % output:
|
|
1033 | 1079 | % BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details
|
1034 | 1080 | %
|
1035 | 1081 |
|
1036 |
| -%==== function varargout = lz4hcencode(varargin) ==== |
| 1082 | +%==== function varargout = lz4encode(varargin) ==== |
1037 | 1083 | %
|
1038 | 1084 | % output = lz4encode(input)
|
1039 | 1085 | % or
|
|
1392 | 1438 | % BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details
|
1393 | 1439 | %
|
1394 | 1440 |
|
1395 |
| -%==== function [dims, maxlevel, count] = nestbracket2dim(str,brackets) ==== |
| 1441 | +%==== function [dims, isndarray, maxlevel, count] = nestbracket2dim(str,brackets,testndarray) ==== |
1396 | 1442 | %
|
1397 |
| -% [dims, maxlevel, count] = nestbracket2dim(str,brackets) |
| 1443 | +% [dims, isndarray, maxlevel, count] = nestbracket2dim(str,brackets) |
1398 | 1444 | %
|
1399 | 1445 | % Extracting the dimension vector of a JSON string formatted array
|
1400 | 1446 | % by analyzing the pairs of opening/closing bracket tokenss; this function
|
|
1409 | 1455 | % if not given, brackets is set to '[]' to find matching square-brackets;
|
1410 | 1456 | % for example, '{}' looks for a matching closing curly-bracket in
|
1411 | 1457 | % the string key(pos(startpos,:end))
|
| 1458 | +% testndarray: (optional), 1 to test if the input string contains an |
| 1459 | +% ND array, i.e. with uniform element lengths (recursively) |
1412 | 1460 | %
|
1413 | 1461 | % output:
|
1414 | 1462 | % dims: the speculated dimension vector with the length matching the maximum
|
1415 | 1463 | % depth of the embedded bracket pairs. When the input string encodes an
|
1416 | 1464 | % N-D array, the dims vector contains all integers; however, returning
|
1417 |
| -% an all-integer dims vector does not mean the array is rectangular. |
| 1465 | +% an all-integer dims vector does not mean the array is |
| 1466 | +% rectangular. if testndarray is set to 1, dims returns isndarray |
| 1467 | +% isndarray: 1 to indicate the input string contains an ND array, |
| 1468 | +% otherwise, 0 |
1418 | 1469 | % maxlevel: return the depth of the enclosed brackets in the string, i.e. the
|
1419 | 1470 | % length of the dims vector.
|
1420 | 1471 | % count: the relative depth from the level 0 - scanning from the left
|
|
0 commit comments