Message from JavaScript discussions

August 2017

— Everything

— 

Yo guys, how call the id and harga in this json ?

[
{
"2017-07-28": [
{
"id": 1,
"produk_id": 1,
"nama_id": 1,
"jumlah_user_id": 1,
"harga": "50000",
"tanggal_efektif": "2017-07-28"
},


i tried to use
                $.each(result[0], function (index,el) {
$('#prosesloadingharga').hide();
console.log("harga paket : " +el.harga+" , id harga paket : "+el.id);
});

and its became undefined.

— JSON.parse( ... json string here ... )

— 

result[0]['2017-07-28'].id
result[0]['2017-07-28'].harga

— Hey mar, i think its can't work :/ since the problem is not that, but its in dimensional(?)

— Ah i see so i need to use two [ ] , but that 2017-07-28 isn't static 🤔

— You can put a variable in the [ ]

— 

date = '2017-07-28';
result[0][date].id

— Its still static i think if we do that in thats way.🤔

— For (x in result){
for(y in result[x]){
console.log(result[x][y]['id']);
}
}

— 

                $.each(result[0]), function(index,el){
$.each(result[0]), function(index,el){
console.log("harga paket : " +el.harga+" , id harga paket : "+el.id);
};
};


do you mean something like this ?

Message permanent page

— No, just run that ^