I have a JSON with this structure:
diferencias = {
"1": {
"1": 543.0,
"0": 542.0
},
"2": {
"0 1": 0.3333333333333333
}
}
I need to obtain a table with outer keys as columns.
I wrote the following code:
$("#pinchetabla").empty()
var tr = ""
for (d in diferencias) {
var r = ''
for (dd in d) {
//console.log(dd)
r += '<tr>' + 'f[' + diferencias.dd + ']=' + diferencias.d.dd + '</tr>'
}
tr += r
}
var table = "<table id='resultados' class='table table-condensed'>" + tr + "</table>"
$("#pinchetabla").append(table)
I've got following jsfiddle
Where pinchetabla is a div. However I can't even properly access the JSON keys and values. What am I missing?
for(dd in d)your needfor (dd in diferencias[d])for a start.