I have an class which consist in which i have some problems filling a jsonElement from a json file as such
{
"entities": [
{
"name": "DateTimeENT1",
"description": "This a example",
"uil": {
"uill": "This is my Layout"
}
}
]
}
which is being deserialized into this class:
public class Container {
public ICollection<Entity> Entities {get; set;}
}
public class Entity {
public string Name {get; set;}
public string Descripton {get; set;}
UIL Uil {get; set;}
}
public class UIL{
JsonElement Uill {get; set;}
}
and this is how I deserialize it:
var input= JsonConvert.DeserializeObject<Container>(File.ReadAllText(@"init.json"));
when i run this I get an error stating that 'Error converting value "This is my Layout" to type 'System.Text.Json.JsonElement'. how do I overcome this?
The weird part about all this is that I can use the same input on my controller endpoint
public IActionResult Put([FromBody] Container container)
which without any problem creates an container, with the given json.. so why does it not work when I do it with the deserializer?
UILandUIVshould be string instead ofJsonElement?"This is my Layout"is just string, not JSON object.