Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search for a specific position in a JSON file?

I'm trying to import a large JSON file but I'm getting this error:

Unexpected token , in JSON at position 197031914

how do i go to that position to fix it?

Thanks!

like image 596
tito.300 Avatar asked Mar 20 '19 20:03

tito.300


3 Answers

Just use a JSON linter. There are plenty online, like this one. The linter will point out the specific errors in the syntax of your JSON file.

like image 191
Jimmy Leahy Avatar answered Oct 20 '22 12:10

Jimmy Leahy


Besides the recommendations of using a json linter, this extension lets you navigate to a specific offset (position) within a file. You'd want to go to offset 197031914.

Keep in mind that if the file has very long lines, VS Code will not display the entire line. You can try adjusting this limit by following these steps

like image 9
Matt Bierner Avatar answered Oct 20 '22 12:10

Matt Bierner


I know this is an older question but since its getting some views I want to mention how I ended up solving this issue.

Because I was processing huge files (gigabytes), it was not working with linters, so I ended up solving this issue by writing my script that takes a readable stream and find that position and then return the context (x number of charachters before and after position).

I still use it and I might get around to publish it on npm for others to use. (not sure if someone had already done a similar thing);

like image 1
tito.300 Avatar answered Oct 20 '22 13:10

tito.300