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
When importing, you should not use JSON.parse(). It's already parsed by cli/webpack
import data from './data.json';
test: any = data;
stack
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With