2016-05-27 26 views
0

このJSONオブジェクトが見つかりました。そして、私はnodes内のすべてのオブジェクトthroug反復処理したいと思いますが、オブジェクトはnodesオブジェクトは[]Javascript - 大括弧なしのJSON配列

とのアレイとしてformatetされていない、私は例の名前を知っていれば、私は、次々にアクセスすることができます。

var X = Trend.L13

var node = X.nodes["AGENT.OBJECTS.House.SKL04_SK2.L13.Frost.AL01"]

しかし、どのように私はそれらを反復処理するのですか?

var Trend = { 


L13: { 
    dataArchive: "datavalues", 
    nodes: { 
     "AGENT.OBJECTS.House.SKL04_SK2.L13.Frost.AL01": { 
     visible: true, 
     axis: "left", 
     style: "Line", 
     color: "#66AF31", 
     linewidth: 1, 
     nonstop: true, 
     stairs: true, 
     configname: "L13", 
     address: "AGENT.OBJECTS.House.SKL04_SK2.L13.Frost.AL01", 
     text: "Frost" 
     }, 
     "AGENT.OBJECTS.House.SKL04_SK2.L13.TempZul.MT01": { 
     visible: true, 
     axis: "right", 
     style: "Line", 
     color: "#8701AF", 
     linewidth: 1, 
     nonstop: true, 
     stairs: false, 
     configname: "L13", 
     address: "AGENT.OBJECTS.House.SKL04_SK2.L13.TempZul.MT01", 
     text: "Temp ZUL" 
     }, 
     "AGENT.OBJECTS.House.SKL04_SK2.L13.PuWrg.SS01": { 
     visible: true, 
     axis: "left", 
     style: "Line", 
     color: "#000", 
     linewidth: 1, 
     nonstop: true, 
     stairs: true, 
     configname: "L13", 
     address: "AGENT.OBJECTS.House.SKL04_SK2.L13.PuWrg.SS01", 
     text: "PuWRG" 
     }, 
     "AGENT.OBJECTS.House.SKL04_SK2.L13.TempWrgVl.MT01": { 
     visible: true, 
     axis: "right", 
     style: "Line", 
     color: "#FF2511", 
     linewidth: 1, 
     nonstop: false, 
     stairs: false, 
     configname: "L13", 
     address: "AGENT.OBJECTS.House.SKL04_SK2.L13.TempWrgVl.MT01", 
     text: "Temp. WRG Vorlauf" 
     }, 
     "AGENT.OBJECTS.House.SKL04_SK2.L13.TempZulNachWRG.MT01": { 
     visible: true, 
     axis: "right", 
     style: "Line", 
     color: "#F99602", 
     linewidth: 1, 
     nonstop: false, 
     stairs: false, 
     configname: "L13", 
     address: "AGENT.OBJECTS.House.SKL04_SK2.L13.TempZulNachWRG.MT01", 
     text: "Temp. ZUL nach WRG" 
     }, 
     "AGENT.OBJECTS.House.SKL04_SK2.L13.VtWrg.SS01": { 
     visible: true, 
     axis: "left", 
     style: "Line", 
     color: "#A5184A", 
     linewidth: 1, 
     nonstop: false, 
     stairs: true, 
     configname: "L13", 
     address: "AGENT.OBJECTS.House.SKL04_SK2.L13.VtWrg.SS01", 
     text: "VT WRG" 
     } 
    }, 
    leftAxis: { 
     visible: "1", 
     autoScale: "1", 
     min: -3.7, 
     max: 37, 
     description: "Linke Achse" 
    }, 
    rightAxis: { 
     visible: "1", 
     autoScale: "0", 
     min: 0, 
     max: 40, 
     description: "Rechte Achse" 
    }, 
    time: { 
     startTime: 1453010899798, 
     endTime: 1453183699799, 
     lastTime: "1", 
     lastTimeValue: 2, 
     lastTimeUnit: "86400" 
    }, 
    newnodes: {} 
    } 
} 
+2

使用コードのこの部分を使用することができますステートメント/ for ...)) 'for(node in X.nodes) ' –

答えて

1

あなたはhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/([..中のために]

var Nodes = Trend.L13.nodes; 
    for(var key in Nodes) { 
     if(Nodes.hasOwnProperty(key)) { 
     console.log(Nodes[key]); 
     // Use Nodes[key] in this case to access individual objects 
     } 
    } 
+0

これは、https://jsfiddle.net/tp5rd6rL/のバイブルです –

関連する問題