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

Serializing custom types into Value, allow named Map instead of Array representation #190

Open
izolyomi opened this issue Feb 1, 2019 · 0 comments · May be fixed by #337
Open

Serializing custom types into Value, allow named Map instead of Array representation #190

izolyomi opened this issue Feb 1, 2019 · 0 comments · May be fixed by #337

Comments

@izolyomi
Copy link

izolyomi commented Feb 1, 2019

Being a newcomer to rmp, I needed some struggle to understand that I have to enable the with-serde feature of the rmpv crate for de/serializing data of type rmpv::Value. So far so good, e.g. now I can nicely convert a type into a Value with mpv::ext::to_value().

However, such Values are always created as Value::Arrays during serialization and there seems to be no way influencing this behavior. For serialization, usually there's a pair of functions where the default serializes into an array (e.g. rmp_serde::encode::to_vec) and there's a variant creating a map (e.g. rmp_serde::encode::to_vec_named). I cannot see anything similar for values, there's only to_value() without to_value_named() or anything similar.

Is there any way to serialize a type into a Value::Map with the current codebase? Would this require extra development efforts within the library? I even thought of customizing rmpv::ext::se::Serializer which seems to cause this behavior, but it's even private in the module.

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

Successfully merging a pull request may close this issue.

1 participant