Require for json files?

How can i make require work for json files?
I’ve tried the following without any luck.

import * as PhoneData from '../utils/data/phone.json';
import * as CountryData from '../utils/data/country.json';
export class ..... 
    private phoneList:{} = require('../utils/data/phone.json');
    private countryList:{} = require('../utils/data/country.json');

This might help you: Load a text file as a string in Ionic 2

Quickest way may be to just export the entire json file as a typescript object. The json should start and end with brackets. In the json file you would just add export const myJson = in front of the first bracket, and then change the file type to .ts. This works for me when I need to get some json in quick.

1 Like