[Rake-devel] JSON.parse string
Torsten@Robitzki.de
Torsten at robitzki.de
Thu Jul 19 08:09:26 UTC 2012
Hello,
I just stumbled over the fact, that the JSON parser from ruby 1.9.2 allows only arrays and objects:
> a = JSON.parse '"fooo"'
JSON::ParserError: 710: unexpected token at '"fooo"'
> a = JSON.parse "[\"a\"]"
=> ["a"]
As a workaround, I can wrap every text into an array and take the first element of the result:
JSON.parse( "[#{a}]" )[ 0 ]
But I wonder if this is the intended behavior and if so, why?
Kind regards
Torsten
More information about the Rake-devel
mailing list