I have a JSON-File with about 700 lines filled with devices and some information about them (i.e. serial number,macadress, port ...).
In another file I have created an object like
type jsonObj = {
serialNumber: string;
macAdress: string;
port: string;
}
And now I want to populate a table with this jsonDevice objects in a loop but somehow I dont get it to work.
My code looks like that:
const ObjectTable: FC = () => {
const entities: jsonObj[] = [
{
serNom: jsonDevices[0].serNom, //jsonDevices is my json file
macAdr: jsonDevices[0].macAdr,
tunPort: jsonDevices[0].tunPort
},
];
FC is an import from react and with the code above it is working. Im receiving a table-output with the data for this line (e.g jsonDevices[0].serNom gives me correctly 123456789) but now I want to automatically fill the whole list/array with all the remaining lines from the json devices. In Java I would have solved it with a loop like that:
for (int i = 0, i<jsonObj.length, i++){
ObjectTable.add(jsonObj[i].serNom);
ObjectTable.add(jsonObj[i].macAdr);
ObjectTable.add(jsonObj[i].tunPort);
}
Please help me. I getting headache from this issue.