-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
TryFromJsValue #1975
Comments
To add to this, going the other way would also be really nice. I would like to be able to convert values of arbitrary Rust types into |
Well, this is already possible for base Rust types. Maybe there should be another trait to make it simpler. In general, I imagine this to work similarly to the |
Having this API implemented would solve a host of issues for my project: demergent-labs/azle#142 I am ready to start working on this as soon as tomorrow, it's a major blocking issue for me. If you would accept a PR let me know, and I would love some guidance. If you want to wait for whatever reason, I would really appreciate some initial guidance as I will need to implement this functionality for myself no matter what. |
I've started working on this, considering two traits |
Working on Azle which is a JS environment for the Internet Computer, I need to have a general solution for converting
JsValue
s into arbitrary types. I have been attempting to do this usingserde_json::from_value(js_value.to_json(& mut context).unwrap()).unwrap()
which works in many cases, but breaks down sometimes (for example withundefined
andbigint
). It's also a more complicated developer experience and probably less performant than a direct conversion fromJsValue
to an arbitrary type would be.The below is from this comment: #1961 (comment)
I would like to start a discussion on some sort of
TryFromJsValue
. Is this something you think boa could/would want to support? If so, what should the API look like?I would like this functionality ASAP and so if it would be accepted and I could receive some guidance, I am happy to do the work. If it's relatively simple for the maintainers to go ahead and do it then I am happy with that as well. Just hope this can be done.
Thanks!
The text was updated successfully, but these errors were encountered: