Skip to content

doesn't fail when parsing "f" or "n" #58

Open
jmettraux opened this Issue Apr 30, 2011 · 0 comments

1 participant

@jmettraux

when parsing "f" and "n", yajl-ruby returns nil (instead of emitting an error).

(https://gist.github.com/949695)

require 'rubygems'
require 'yajl'
require 'yajl/version'
require 'json'

puts `uname -a`
p [ :ruby, RUBY_VERSION ]
p [ :json, JSON::VERSION ]
p [ :yajl, Yajl::VERSION ]

p begin
  JSON.parse('f')
rescue
  :json_error
end
p begin
  JSON.parse('n')
rescue
  :json_error
end

p begin
  Yajl::Parser.parse('f')
rescue
  :yajl_error
end
p begin
  Yajl::Parser.parse('n')
rescue
  :yajl_error
end

emits

Darwin sanma.local 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386
[:ruby, "1.9.2"]
[:json, "1.4.2"]
[:yajl, "0.8.2"]
:json_error
:json_error
nil
nil

Tested with 1.8.7-p249 and 1.9.2-p180 on Snow Leopard. Using vanilla RVM.

Same thing on a Debian system (vanilla RVM) :

Linux li162-226 #1 SMP Sun Jul 25 21:32:42 UTC 2010 i686 GNU/Linux
[:ruby, "1.8.7"]
[:json, "1.5.1"]
[:yajl, "0.8.2"]
:json_error
:json_error
nil
nil

Kind regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.