1

I faced with a problem parsing json file with yajl-ruby. It shows an error of this kind:

'parse': lexical error: invalid char in json text. (Yajl::ParseError)

                   {     "inquiry":         {         "
(right here) ------^

I have tried to open a file with utf-8 encoding explicitly, but it doesn't help. The strange part of it that it raises error on a curly brace.

4

1 回答 1

1

The reason was that I have opened a file encoded in UTF-8 with BOM. To fix this error, I was needed to open a file with following options:

File.open(@file, 'r:bom|utf-8')

于 2015-04-06T12:20:52.693 回答