R
R
raft882018-03-09 03:03:14
JavaScript
raft88, 2018-03-09 03:03:14

How to fix error when importing json file?

Hey!
As long as the json file of the format:
{
"data": [{...}, {...}, {...}]
}
the line import data from 'path_to_file.json' works correctly
. The assembly is done by webpack.
If you change json to:
{
"data": [{...}, {...}, {...}],
"anotherData": [{...}, {...}, {. ..}]
}
throws a Syntax error: Unexpected string in JSON at position ххххх

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-03-09
@raft88

I dare to suggest that the error is in nested objects in the anotherData array . All keys must be in quotes and there should be no extra commas. Validator to help you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question