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

Suggested update - function handles #51

Closed
will-hill opened this issue Feb 13, 2019 · 2 comments
Closed

Suggested update - function handles #51

will-hill opened this issue Feb 13, 2019 · 2 comments

Comments

@will-hill
Copy link

will-hill commented Feb 13, 2019

Hi Fang,
I find this project useful for a current project. Below is a change I made that you might find helpful. I needed to serialize/deserialize function handles in Octave. I do not know if it will work with Matlab.

182c182,185
< else
---
> elseif(is_function_handle(item))
> function_handle_struct = functions(item);
> txt=struct2json(name,function_handle_struct,level,varargin{:});
> elseif(ismatrix(item))
183a187,188
> else
> error('what is this object type?');

@fangq
Copy link
Member

fangq commented Feb 14, 2019

thanks @will-hill, I'd love to accept this update, but would prefer the change to be compatible with both matlab and octave. can you use this test as an example to refine your patch?

https://github.com/fangq/jsonlab/blob/master/savejson.m#L177

once it works with both, would be nice to send me a pull request (I am happy to manually patch if you have trouble doing so).

@fangq fangq closed this as completed in 9c01046 Mar 13, 2019
@fangq
Copy link
Member

fangq commented Mar 13, 2019

now saving function handle is supported. try

fun=@sin;
savejson('',fun)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants