How to import a JSON file in ECMAScript 6?

In TypeScript or using Babel, you can import json file in your code.

// Babel

import * as data from './example.json';
const word = data.name;
console.log(word); // output 'testing'

Reference:
https://hackernoon.com/import-json-into-typescript-8d465beded79

Leave a Comment