Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
jsonlab/saveubjson.m at master · NeuroJSON/jsonlab · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
NeuroJSON
jsonlab
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
jsonlab
/
saveubjson.m
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
72 lines (71 loc) · 3.15 KB
master
Breadcrumbs
jsonlab
/
saveubjson.m
Copy path
Top
File metadata and controls
Code
Blame
72 lines (71 loc) · 3.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
function
ubj
=
saveubjson(
rootname
,
obj
,
varargin
)
%
%
ubj=saveubjson(obj)
%
or
%
ubj=saveubjson(rootname,obj,filename)
%
ubj=saveubjson(rootname,obj,opt)
%
ubj=saveubjson(rootname,obj,'param1',value1,'param2',value2,...)
%
%
Convert a MATLAB object (cell, struct, array, table, map, graphs ...)
%
into a Universal Binary JSON (UBJSON, Draft-12) or a MessagePack binary stream
%
%
author: Qianqian Fang (q.fang <at> neu.edu)
%
initially created on 2013/08/17
%
%
Format specifications:
%
Binary JData (BJData):https://github.com/NeuroJSON/bjdata
%
UBJSON: https://github.com/ubjson/universal-binary-json
%
MessagePack: https://github.com/msgpack/msgpack
%
%
This function is the same as calling "savebj(..,'ubjson',1,'endian','B')"
%
By default this function creates UBJSON-compliant output without the
%
newly added uint16(u), uint32(m), uint64(M) and half-precision float (h)
%
data types and use Big-Endian for all numerical values as in UBJSON
%
Draft-12.
%
%
This function by default still enables an optimized ND-array format for efficient
%
array storage. To ensure the output compatible to UBJSON Draft-12, one should use
%
"saveubjson(...,'NestArray',1)" or "savebj(...,'ubjson',1,'NestArray',1)"
%
%
input:
%
rootname: the name of the root-object, when set to '', the root name
%
is ignored, however, when opt.ForceRootName is set to 1 (see below),
%
the MATLAB variable name will be used as the root name.
%
obj: a MATLAB object (array, cell, cell array, struct, struct array,
%
class instance)
%
filename: a string for the file name to save the output UBJSON data
%
opt: a struct for additional options, ignore to use default values.
%
opt can have the following fields (first in [.|.] is the default)
%
%
opt can be replaced by a list of ('param',value) pairs. The param
%
string is equivalent to a field in opt and is case sensitive.
%
%
Please type "help savebj" for details for all supported options.
%
%
output:
%
ubj: a binary string in the UBJSON format (see http://ubjson.org)
%
%
examples:
%
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],...
%
'MeshTet4',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],...
%
'MeshTri3',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;...
%
2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],...
%
'MeshCreator','FangQ','MeshTitle','T6 Cube',...
%
'SpecialData',[nan, inf, -inf]);
%
saveubjson(jsonmesh)
%
saveubjson('',jsonmesh,'meshdata.ubj')
%
saveubjson('mesh1',jsonmesh,'FileName','meshdata.msgpk','MessagePack',1)
%
saveubjson('',jsonmesh,'KeepType',1)
%
%
license:
%
BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details
%
%
-- this function is part of JSONLab toolbox (http://neurojson.org/jsonlab)
%
if
(
nargin
==
1
)
ubj
=
savebj(
'
'
,
rootname
,
'
ubjson
'
,
1
,
'
endian
'
,
'
B
'
);
elseif
(length(
varargin
)
==
1
&&
ischar(varargin{
1
}))
ubj
=
savebj(
rootname
,
obj
,
'
FileName
'
, varargin{
1
},
'
ubjson
'
,
1
,
'
endian
'
,
'
B
'
);
else
ubj
=
savebj(
rootname
,
obj
, varargin{
:
},
'
ubjson
'
,
1
,
'
endian
'
,
'
B
'
);
end
You can’t perform that action at this time.