Reputation: 4586
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.
Upvotes: 1
Views: 1880
Reputation: 4586
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')
Upvotes: 1