I receive a Json file. Now the other company change the Json and I have to find the right format for my class in C.Net and I’m not able to do so.
My Json looks like :
{
{"xxx": [
"d6952cb5c",
"8587d4",
"96b4d",
"622201a",
"55e0d455"
],
"yyy": [
"28f054091d"
],
"zzz": []
}
The thing is, I don’t know the name of the field I’m going to receive. So I’m not able to create a class with the correct field replacing xxx, yyy and zzz. I can receive more than 300 of these.
Normally I had create my class like this :
public class Root
{
public List<string> xxx { get; set; }
public List<string> yyy { get; set; }
public List<object> zzz { get; set; }
}
Someone has an idea on How I can create the right class, Or any other way to have my data in an object or a dictionary to read them separately ?
thanks
2
Answers
Finally working on my side, with some other solutions, I found somethig that works. Here's the code help with another stack overflow.
Find the solution with another stackoverflow here: dynamic JContainer (JSON.NET) & Iterate over properties at runtime
The easiest way for this specific example is to use
Dictionary<string, string[]>
to deserialize object:You will get this output: