Mam tablicę obiektów, w których są kolejne podobiekty. Po wypisaniu ich poniższym kodem:
for (index in groups)
{
for (index2 in groups[index])
{
console.log(JSON.stringify(groups[index][index2],null,4));
}
}
, otrzymałem taki output:
"processors"
[
{
"producent": "INTEL",
"model-line": "i7",
"model": "720QM",
"freq": "2.8",
"cores": "4",
"threads": "8",
"quantity": "5",
"netto_price": "450.25\r",
"brutto": 549.3,
"tara": 99.05
},
{
"producent": "INTEL",
"model-line": "i5",
"model": "4570",
"freq": "3.2",
"cores": "4",
"threads": "4",
"quantity": "4",
"netto_price": "345.50\r",
"brutto": 421.51,
"tara": 76.01
},
{
"producent": "AMD",
"model-line": "ATHLON",
"model": "7750",
"freq": "2.6",
"cores": "6",
"threads": "2",
"quantity": "7",
"netto_price": "250.00\r",
"brutto": 305,
"tara": 55
}
]
"graphics"
[
{
"producent": "AMD",
"model_line": "RADEON",
"model": "7790",
"vram": "1GB",
"directx": "11",
"quantity": "3",
"netto_price": "300.90\r",
"brutto": 367.1,
"tara": 66.2
},
{
"producent": "NVIDIA",
"model_line": "GEFORCE",
"model": "8800GTS",
"vram": "512MB",
"directx": "10",
"quantity": "1",
"netto_price": "150.99\r",
"brutto": 184.21,
"tara": 33.22
}
]
"motherboards"
[
{
"producent": "ASUS",
"model_line": "RAMPAGE",
"model": "MAXIMUS-VII",
"chipset": "Z87",
"quantity": "6",
"netto_price": "890.99\r",
"brutto": 1087.01,
"tara": 196.02
},
{
"producent": "MSI",
"model_line": "GAMING",
"model": "GD-65",
"chipset": "Z87",
"quantity": "5",
"netto_price": "510.30\r",
"brutto": 622.57,
"tara": 112.27
},
{
"producent": "ASUS",
"model_line": "UNKNOWN",
"model": "P5KC",
"chipset": "P35",
"quantity": "1",
"netto_price": "50.00",
"brutto": 61,
"tara": 11
}
]
W jaki sposób to wypisać, aby każdy podobiekt (czyli to, co zaczyna się od wyrazu "PRODUCENT") było w nowej linii, tak samo jak w poniższej formie? http://imgur.com/1Ecgscy