For example, there's an object like the next one:
public class Container
{
public object Data { get; set; }
}
And it's used this way:
Container container = new Container
{
Data = new Dictionary<string, object> { { "Text", "Hello world" } }
};
If I deserialize a JSON string obtained from serializing the above instance, the Data
property, even if I provide the ExpandoObjectConverter
, it's not deserialized as an ExpandoObject
:
Container container = JsonConvert.Deserialize<Container>(jsonText, new ExpandoObjectConverter());
How can I deserialize a class property assigned with an anonymous object, or at least, not concrete type as an ExpandoObject
?
EDIT:
Someone answered that I could just use the dynamic object. This won't work for me. I know I could go this way, but this isn't the case because I need an ExpandoObject. Thanks.
EDIT 2:
Some other user answered I could deserialize a JSON string into an ExpandoObject
. This isn't the goal of this question. I need to deserialize a concrete type having a dynamic property. In the JSON string this property could be an associative array.