我有一个 JSON 编码的数组,看起来像这样(注意:这是在文件中,而不是字符串的内容)["Company\\","NN","Company\\"]
:。这是无效的 JSON 吗?它包含一个转义\
字符,在我看来是正确的。然而:
a = '["Company\\","NN","Company\\"]'
=> "[\"Company\\\",\"NN\",\"Company\\\"]"
JSON.parse a
JSON::ParserError: 387: unexpected token at 'NN","Company\"]'
from /Users/nneubauer/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/json/common.rb:148:in `parse'
from /Users/nneubauer/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/json/common.rb:148:in `parse'
from (irb):11
from /Users/nneubauer/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'
有趣的是:
puts a
["Company\","NN","Company\"]
我究竟做错了什么?