Transform Json

  • Thread starter Thread starter diegodamage82
  • Start date Start date
D

diegodamage82

Guest
Hi.

I get a list from this code: var mediosdepago = _context.Test.FromSqlRaw("EXECUTE Sp_ObtenerMedioDePago @IdCanalDePago={0}, @IdPais={1}", idCanalDePago, idPais).ToList();

How can I do to convert the resulting Json

[
{
"idMedioDePago": 6,
"medioDePago": "Tarjeta Credito (PayU)",
"idFranquicia": 1,
"franquicia": "Visa",
"idMedioDePagoPresencial": null,
"medioDePagoPresencial": null
},

{
"idMedioDePago": 7,
"medioDePago": "Pago Presencial",
"idFranquicia": null,
"franquicia": null,
"idMedioDePagoPresencial": 1,
"medioDePagoPresencial": "Efecty"
},

{
"idMedioDePago": 8,
"medioDePago": "Tarjeta Debito (PSE)",
"idFranquicia": null,
"franquicia": null,
"idMedioDePagoPresencial": null,
"medioDePagoPresencial": null
}
]

to the next json where the nodes depend on the null values:

[{
"idMedioDePago": 6,
"medioDePago": "Tarjeta Credito (PayU)",
"Franquicia": {
"id": 1,
"nombre": "Visa"
}
}, {
"idMedioDePago": 7,
"medioDePago": "Pago Presencial",
"MedioDePagoPresencial": {
"id": 1,
"nombre": "Efecty"
}
}, {
"idMedioDePago": 8,
"medioDePago": "Tarjeta Debito (PSE)"
}]


Thanks in advance.

Continue reading...
 
Back
Top