3

In general as noted here it's pretty straight forward:

import data from './data.json';

However this does not work in Stackblitz Angular projects.

The linked project logs the following:

preview-3a0c9433aa42f56dbd90b.js:1 SyntaxError: Unexpected token o in JSON at position 1
Ole
  • 41,793
  • 59
  • 191
  • 359

1 Answers1

5

When importing, you should not use JSON.parse(). It's already parsed by cli/webpack

import data from './data.json';

test: any = data;

stack

Poul Kruijt
  • 69,713
  • 12
  • 145
  • 149