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

0

1 Answer 1

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;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.