Yajl.load does not always throw on parse errors. For example:
irb(main):004:0> Yajl.load('[[],"NOOOOOOOOOOOoooooooooooo!')
=> [[]]
It just ignored that tiny little detail at the end, and continues with what it got to that point. I want it to throw if the entire string as whole is bad, like the native JSON.parse method does:
irb(main):005:0> JSON.parse('[[],"NOOOOOOOOOOOoooooooooooo!')
JSON::ParserError: 399: unexpected token at '"NOOOOOOOOOOOoooooooooooo!'
from /home/me/.rvm/gems/ruby-1.9.3-p392/gems/json-1.7.5/lib/json/common.rb:155:in `parse'
from /home/me/.rvm/gems/ruby-1.9.3-p392/gems/json-1.7.5/lib/json/common.rb:155:in `parse'
from (irb):5
...
Is there any way to enforce a 'strict' mode in YAJL? Or will I need to run it through the native JSON.parse call each time to validate it if I wish to be sure I am operating on a legal JSON string?
This is an issue already open in the yajl project. Unfortunately, it has not been fixed yet.
Maybe give the issue a +1, or ask there why the issue is not handled nor responded to.