Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question