Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

any2jd: raise error if object cannot be converted #96

Merged
merged 1 commit into from
Aug 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions jdataencode.m
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,15 @@

%% -------------------------------------------------------------------------
function newitem = any2jd(item, varargin)

N = @(x) N_(x, varargin{:});
newitem.(N('_DataInfo_')) = struct('MATLABObjectClass', class(item), 'MATLABObjectSize', size(item));
newitem.(N('_ByteStream_')) = getByteStreamFromArray(item); % use undocumented matlab function
if (varargin{1}.base64)
newitem.(N('_ByteStream_')) = char(base64encode(newitem.(N('_ByteStream_'))));
try
N = @(x) N_(x, varargin{:});
newitem.(N('_DataInfo_')) = struct('MATLABObjectClass', class(item), 'MATLABObjectSize', size(item));
newitem.(N('_ByteStream_')) = getByteStreamFromArray(item); % use undocumented matlab function
if (varargin{1}.base64)
newitem.(N('_ByteStream_')) = char(base64encode(newitem.(N('_ByteStream_'))));
end
catch
error('any2jd: failed to convert object of type %s', class(item));
end

%% -------------------------------------------------------------------------
Expand Down
Loading