From: Eric Mahurin Date: 2008-02-04T01:51:44+09:00 Subject: Re: [QUIZ] Parsing JSON (#155) ------=_Part_2665_29955877.1202057507703 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Feb 1, 2008 7:55 AM, Ruby Quiz wrote: > http://json.org/ This doc is missing two things: 1) exactly what is allowed for the top-level json, and 2) where can whitespace appear. This is more complete: http://www.ietf.org/rfc/rfc4627.txt def test_keyword_parsing > assert_equal(true, @parser.parse("true")) > assert_equal(false, @parser.parse("false")) > assert_equal(nil, @parser.parse("null")) > end > > def test_number_parsing > assert_equal(42, @parser.parse("42")) ... > end > > def test_string_parsing > assert_equal(String.new, @parser.parse(%Q{""})) ... > end > The above isn't legal JSON. An array or object (hash) should be at the top-level. Surround these by brackets and it will be legal. ------=_Part_2665_29955877.1202057507703--