typescript read json file

JavaScript
add to tsconfig.json

{
	...
    "resolveJsonModule": true
  }
}// data.json:
{
"greeting" : "xin chao Vietnam"
}
// component:
import * as data from 'data.json';
let greeting = data.greeting;
//registering jsonModule in tsconfig.json
"compilerOptions": {
    ....
    "resolveJsonModule": true,
    ....
  },"resolveJsonModule": true,
"esModuleInterop": true,
import {default as a} from "config.json";
config.targetKey
// this requires `"resolveJsonModule": true` in tsconfig.jsonimport {default as a} from "a.json";
a.primaryMain
Source

Also in JavaScript: