A moment ago I saw a very interesting question about how to generate a DataSet based on a generic list that comes from a JSON , since the question was deleted and I managed to copy the JSON structure , here is a collaboration with the community:
[
{
"CO_EMPR": "18",
"TI_REQI": "RAL",
"NU_REQI": "0001-0000000049",
"SECUENCIA": "4",
"CODIGO_ITEM": "600101008",
"CANTIDAD_SOLICITADA": "5"
},
{
"CO_EMPR": "18",
"TI_REQI": "RAL",
"NU_REQI": "0001-0000000049",
"SECUENCIA": "5",
"CODIGO_ITEM": "600401036",
"CANTIDAD_SOLICITADA": "5"
}
]
First of all, when working with conversions of such structures, you need to "parse" the JSON to a class or a list of classes. Second, only when you have the JSON "parsed" with a class or list, you proceed to make the transformation.
The question caught my attention, since it plays with Generics and Reflection to achieve the requested functionality.
Since I didn't know the data type values, I put in a simple class (IndividualElement) with pure string properties and an additional class generated courtesy of Mockaroo .
Without further details to add, to the code:
And here we have what is generated by GetXML()