0
我有此JSON在JS和需要循環的一部分:我需要循環此JSON在JS
"valores_p_prom":{"178":[{"Custo_sem_com_h":6,"Custo_c_com_h":16,"Total_horas":6,"Custo_hora":"normal","Com_h":10,"APagProm":36,"pay":60}],"185":[{"Custo_sem_com_h":5,"Custo_c_com_h":15,"Total_horas":6,"Custo_hora":"baixo","Com_h":10,"APagProm":30,"pay":60}]}
完整JSON:
[{"Evento":"rr","JobId":"735","Datas":[{"dia":"2017-08-20","inicio":"5:00","fim":"11:00","n_horas":6}],"Morada":"r","Localidade":"Lisboa","Descriçao":"rr","npromotoras":"1","Soma_de_Horas":6,"Prom_escolhidas":["185","178"],"valores_p_prom":{"178":[{"Custo_sem_com_h":6,"Custo_c_com_h":16,"Total_horas":6,"Custo_hora":"normal","Com_h":10,"APagProm":36,"pay":60}],"185":[{"Custo_sem_com_h":5,"Custo_c_com_h":15,"Total_horas":6,"Custo_hora":"baixo","Com_h":10,"APagProm":30,"pay":60}]},"a_pagar":"186€","client_pagaiva":"229.48","cliente":"Greenmov","cliente_email":"[email protected]","cliente_id":"36"}]
我已經tryed:
var oo=JSON.parse(row[i].ev_fire);
var iu=oo[0].valores_p_prom;
if (iu===undefined) {} else {
$.each(iu, function(key, value) {
//arr.push(value);
console.log("key => "+key);//will output: 04c85ccab52880 and all such
$.each(value, function(ky, val) {
console.log('ky => '+ky[APagProm]);//will output: name, firstname, societe
console.log('val => '+val);//will output: name1, fname1, soc1
});
});
but i get key => 178
val => [object Object]
請helpme