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

Unable to decode Dictionary<string, object> #157

Open
goncalo-oliveira opened this issue Jul 2, 2021 · 1 comment
Open

Unable to decode Dictionary<string, object> #157

goncalo-oliveira opened this issue Jul 2, 2021 · 1 comment

Comments

@goncalo-oliveira
Copy link
Contributor

Consider the following structure

public class Person
{
    public string Name { get; set; }
    public Dictionary<string, object> Metadata { get; set; }
}

The encoder doesn't seem to have an issue and serializes the dictionary correctly; here's the encoded value ToString().

ObjectV(name: StringV(Japanfy),metadata: ObjectV(comm.status: StringV(connected),comm.satellites: LongV(8)))

However, the decoder doesn't behave well with this and doesn't decode the values of the dictionary. It just creates an empty object for each.

{"Name":"Japanfy","Metadata":{"comm.status":{},"comm.satellites":{}}}
@goncalo-oliveira
Copy link
Contributor Author

As per discussed in the Slack channel...

What object should we use to decode when we find an object?

If the value is a StringV, then it should be a string, for example.

When we are encoding, what matters is the actual object type. So, when we are decoding, shouldn't we consider using the value type?

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

1 participant