faunadb-csharp
faunadb-csharp copied to clipboard
Unable to decode Dictionary<string, object>
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":{}}}
As per discussed in the Slack channel...
What object should we use to decode when we find an object?
- @marrony
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?