O
O
Olga Mironova2019-07-04 07:25:00
JavaScript
Olga Mironova, 2019-07-04 07:25:00

It gives the error Uncaught SyntaxError: Unexpected token o in JSON at position 1, what is it?

Tell me, what is the error "Uncaught SyntaxError: Unexpected token o in JSON at position 1"? I googled it, it's invalid json, but it's valid, I checked it through an online program. It starts with the fact that I import my json file into the react component.
1. json is in the Data folder of the src directory
2. when I try to import it into the App component, it does not see it, that is, it does not even complement visual studio when I enter import data from '../../Data/ and then does not see the file', the file has a .json extension
3. installed json-loader, maybe you need to not just install it, do you need some other manipulations? Ps loader
4 appeared in package.json. then I try to write my json to a variable, but it gives this error. const response = JSON.parse(data)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-07-04
@olgamiro1990

This [object Object]is the default string representation of objects. If the first argument passed to JSON.parse is not a string, it will be converted to a string. You are trying to parse an object. There is no need to use JSON.parse, everything is already as it should.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question