Unfortunately, you can't create the JSON that you are after because what you are after is not valid JSON. I know that sentence sounds a bit odd, but let me explain. In one part, you have the following:
{
"NombreCliente:" Jose perez,
"Cantidad Paquete" 20,
"Estatus": "Disponible",
"Cantidad Paquete": "10",
"Estatus": "En aduana"
}
You cannot have repeating key/value pairs in the same portion of JSON. Where you have Cantidad Paquete and Estatus, you can only have one of these present. What you need to do here is create an array of attributes to represent these elements. Something like this:
{
"NombreCliente:" Jose perez",
"Details" [
"Item": {
"Cantidad Paquete": 20,
"Estatus": "Disponible"
},
"Item": {
"Cantidad Paquete": 10,
"Estatus": "En aduana"
}
]
}
How this maps back to your original request is going to depend on what you want to pull out of the original details. Assuming you want it to look like this:
{
"NombreCliente:" Jose perez",
"ClienteID": "A-32222",
"Mercancia": "Un libro",
"Details" [
"Item": {
"Cantidad Paquete": 20,
"Estatus": "Disponible"
},
"Item": {
"Cantidad Paquete": 10,
"Estatus": "En aduana"
}
]
}
If that's what you wanted to display, you would have to map between the two lists based on a key value that is shared (e.g. the ClienteID). Once you have your classes in place, you could use LINQ to help shape the population of the data.