0

How to convert data from this json file into object and display it in a table

{
"AndraPradesh": {
"dData": {
  "Anantapur": {
    "notes": "",
    "history":2
    "delta": {
      "force": 0
    }
  }
},
"sCode": "AP"
},

"Maharastra": {
"dData": {
  "Pune": {
    "notes": "",
    "history":2
    "delta": {
      "force": 0
    }
  }
},
"sCode": "MH"
},

}

I created an interface as below

export interface DataInterface {
    sName: string[];
    dName: dData[];
    sdCode: string;
}

export interface dData{
    name: string;
    notes: string;
    history: number;
    delta: Delta[];
}

interface Delta {
    force: number;
}

I have also created a class file. I'm not sure whether the above json can be converted into objects in order to assign it to any variable for further operations

Kirataka
  • 484
  • 8
  • 26

1 Answers1

0

I noticed that your DataInterface.dName is an array, meanwhile it is not from what you displayed.

Check the answer here : https://stackoverflow.com/a/40421495/14498619

let jsonObj: any = JSON.parse(employeeString); // string to generic object first
let employee: Employee = <Employee>jsonObj;
Ged Clack
  • 1
  • 2