Angular 12 import json into ts
Following should be placed in tsconfig.json
{ ... "compilerOptions": { ... "resolveJsonModule": true, //already there "esModuleInterop": true, ... },..."allowSyntheticDefaultImports": true}
and then simply import the following in your component
import VersionInfo from 'src/assets/version.json';
import { default as VersionInfo } from 'src/assets/version.json';
You need the two tsconfig entries mentioned above too.
You can try in the tsconfig.json
as:
"compilerOptions": { "allowSyntheticDefaultImports":true }
And import:
import VersionInfo from 'src/assets/version.json';