What to do when your JSON string is not parsing?
So I have a JSON string that I want to parse into a JSON object:
{:wagon_name=>"32155", :assembly_names=>[]}
But it’s not parsing: are there any ruby/rails developers who can see why?
I couldn’t for the life of me work it out. The only clue that I had was this:
SyntaxError: Unexpected token in object literal (line 3, file “Code”)
So it seems that there was something wrong with the JSON object. But how, and where?
ENTER: JLint
JLint tells you what’s wrong.
I found a lovely online JLint site - here: and then I immediately realised that I was using a ruby hash rather than a JSON object. Doh!
This illustrates the importance of testing every step of the way!
HTH
Written on May 25, 2017