Я хочу преобразовать данные из API в tabledata. var serverdata будет заполняться циклом foreach.
первый цикл заполняет данные сервера.
var serverdata = {
0: {certname: "server1", environment: "production", name: "id", value: "PROD\server1$"}
1: {certname: "server1", environment: "production", name: "fqdn", value: "server1.prod.com
2: {certname: "server1", environment: "production", name: "domain", value: "prod.com
3: {certname: "server1", environment: "production", name: "osfamily", value: "windows"}
4: {certname: "server1", environment: "production", name: "uptime", value: "11 days"}
5: {certname: "server1", environment: "production", name: "network", value: "192.168.0.1"}
6: {certname: "server1", environment: "production", name: "virtual", value: "physical"}
7: {certname: "server1", environment: "production", name: "hostname", value: "server1"}
8: {certname: "server1", environment: "production", name: "serverphase", value: "in use"}
}
Первый вывод должен быть:
var tabledata = {
0: {hostname: "server1", id: "PROD\server1$", fqdn: "server1.prod.com", domain: "prod.com", osfamily: "windows", uptime: "11 days", network: "192.168.0.1", virtual: "physical", serverphase: "in use" }
}
Затем цикл заполняет данные сервера новыми данными.
var serverdata = {
0: {certname: "server2", environment: "production", name: "id", value: "acc\server2$"}
1: {certname: "server2", environment: "production", name: "fqdn", value: "server1.acc.com
2: {certname: "server2", environment: "production", name: "domain", value: "acc.com
3: {certname: "server2", environment: "production", name: "osfamily", value: "windows"}
4: {certname: "server2", environment: "production", name: "uptime", value: "13 days"}
5: {certname: "server2", environment: "production", name: "network", value: "192.168.0.2"}
6: {certname: "server2", environment: "production", name: "virtual", value: "physical"}
7: {certname: "server2", environment: "production", name: "hostname", value: "server2"}
8: {certname: "server2", environment: "production", name: "serverphase", value: "in use"}
}
Следующие выходные данные должны быть:
var tabledata = {
0: {hostname: "server1", id: "PROD\server1$", fqdn: "server1.prod.com", domain: "prod.com", osfamily: "windows", uptime: "11 days", network: "192.168.0.1", virtual: "physical", serverphase: "in use" }
1: {hostname: "server2", id: "acc\server2$", fqdn: "server2.acc.com", domain: "acc.com", osfamily: "windows", uptime: "13 days", network: "192.168.0.2", virtual: "physical", serverphase: "in use" }
}
и т. Д.