It seems though, if I may say so, that *cough* certain solutions don't pass all test cases: assert_raise(RuntimeError) { @parser.parse(%{[], p "Foo"}) } assert_raise(RuntimeError) { @parser.parse(%{""; p 123; "Foo"}) } assert_raise(RuntimeError) { @parser.parse(%{"" p 123; ""}) } From the original set: assert_raises(RuntimeError) { @parser.parse("-5.-4") } assert_raises(RuntimeError) { @parser.parse(%Q{{ "a" : 2, }}) } assert_raise(RuntimeError) { @parser.parse(%q{true false}) } My eval() based solution seems to fail on A Stedile's test case unless the more strict rfc-rules, which allow only array and object at the top level, are applied: assert_raise(RuntimeError) { @parser.parse(%Q{"a" "b"}) } Thomas.