Question: I have a JSON file with the following content:

```
{
  "tables": [
    {
      "columns": [
        "Id",
        "Name",
        "Age"
      ],
      "data": [
        [
          "1",
          "John",
          "20"
        ],
        [
          "2",
          "Jessy",
          "34"
        ],
        [
          "3",
          "James",
          "29"
        ],
        ...
      ], ...
  ]
}

```

The target is to archieve a Key-Value-Pair like this:

```
[
  {
    "Id": "1",
    "Name": "John",
    "Age": "20"
  },
  ...
]

```

I guess I can use the KeyValue-Interface by Angular, but I didn't get the result like above. I tried the following, but the result is wrong.

```
Component:
...
import { KeyValue } from '@angular/common';
...
keyValueData: KeyValue<string, string>;

ngOnInit() {
  this.getData();
}

getData() {
  this.dataService.getAllData()
      .subscribe(resp => {
        this.keyValueData = 
          {
            key: resp['tables'][0]['columns'],
            value: resp['tables'][0]['data']
          };
  });
}

```

Have anyone an idea?

Answer: 
If your json looks like this 

```
 {
  "tables": [
    {
      "columns": [
        "Id",
        "Name",
        "Age"
      ],
      "data": [
        [
          "1",
          "John",
          "20"
        ],
        [
          "2",
          "Jessy",
          "34"
        ],
        [
          "3",
          "James",
          "29"
        ],
      ]
   }
  ]
}

```

You can get your desired result like this.You can change component code like below.

```
getData() {
  this.dataService.getAllData()
      .subscribe(resp => {
    var result=[];
    var column = [];
    resp.tables.forEach((table)=>{
    column=table.columns;
    table.data.forEach((data)=>{
    if(data.length == column.length){
      var tempData = {};
      column.map((cldata,index)=>{
      tempData [cldata]=data[index]
     });
      result.push(tempData );
    }
     });
   });
   console.log(result);
   this.keyValueData=result;
  });
}

```
You can create interface some thing like this

```
export interface IKeyValue<T> {
    key: string;
    value: T;
}

```

and You can pass the value type whatever you want to use , t is a generic type here and key will be always String.