Skip to content

Instantly share code, notes, and snippets.

@Heavyblade
Created August 18, 2020 13:26
Show Gist options
  • Save Heavyblade/35e882d668f713c3048663170b7d0371 to your computer and use it in GitHub Desktop.
Save Heavyblade/35e882d668f713c3048663170b7d0371 to your computer and use it in GitHub Desktop.
json.js
/**
* ------------------------------------------------------------------------------------------
* Armamos el JSON de retorno
* ------------------------------------------------------------------------------------------
**/
var json = {};
var PedidosCabecera = oJson_laListaPedidos.vta_ped_g; // JSON con datos de la cabecera
var PedidosLineas = oJson_lineas.vta_ped_lin_g; // JSON con datos de las lineas. (Plural)
for (var key in PedidosCabecera) {
var idPedido = PedidosCabecera[key].id;
PedidosCabecera[key].lineas = [];
for( var j in PedidosLineas) {
if (idPedido === PedidosLineas[j].vta_ped) {
PedidosCabecera[key].lineas.push(PedidosLineas[j]);
}
}
}
alert(JSON.stringify(PedidosCabecera));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment