const jsonArray = [
{
"name": "John",
"age": 30,
"city": "New York",
"cars": [
{ "name": "Ford", "models": ["Fiesta", "Focus", "Mustang"] },
{ "name": "BMW", "models": ["320", "X3", "X5"] },
{ "name": "Fiat", "models": ["500", "Panda"] }
],
"address": {
"street": "5th Avenue",
"number": 10
}
},
{
"name": "Jane",
"age": 25,
"city": "San Francisco",
"cars": [
{ "name": "Toyota", "models": ["Corolla", "Camry", "Rav4"] },
{ "name": "Nissan", "models": ["Altima", "Sentra", "Maxima"] },
{ "name": "Honda", "models": ["Civic", "Accord", "CR-V"] }
],
"address": {
"street": "Market Street",
"number": 20
}
}
];
I have a json as an input like this and most importantly the json format is not fixed so I cannot design any c# model. I need to generate a table like this using the json:
Important points are:
- Every table will have an extra column Id.
- If it’s a property or field, then it will be pushed to the current table.
- If it’s an object or array, a new table will be created using that object/array and a reference id of parent table will be stored.