Roman
Roman

Reputation: 77

JSON.parse Issues

so, I am working on a website for a client, a friend of mine. He sells geckos, and he has made a website for himself, and his sales partner, and I am doing a lot of javascript work for him, IE AJAX, etc... Well, I got to the available lizard page for him, and I am making a sort of dynamic gecko selection system. The way this script is supposed to work is, fetch a JSON file (here) which is perfectly good JSON, and then parse the values in to multiselects. I'm using the jQuery.get function to do this. All goes well until I try parsing the JSON data, and the browser, firefox, throws the error "Syntax Error: JSON.parse", and chromium throws the error "Unexpected Token", the problem also occurred with
The error is thrown on line 219 of js.js,

jQuery.parseJSON(). 


the issues are in the function drawCat(data), the page this code is in use on is Here

I hope that this is a quality question, I'm really quite tired to be coding right now, it pretty late.

Upvotes: 1

Views: 4607

Answers (2)

Mikael Eliasson
Mikael Eliasson

Reputation: 5227

Actually that is not valid JSON. It's easy to check at http://jsonlint.com/. The error is that the root should be either one JSON object or an array. Now you have several JSON objects as roots.

Update: Danjah is also correct. After you fix this the problem he highlights will also cause invalid JSON. so you need to fix both.

Upvotes: 2

danjah
danjah

Reputation: 3059

I don't think its valid, there's a bunch of missing commas part way down the file, screenshot attached as no line numbering.enter image description here

Upvotes: 1

Related Questions