brianmario / yajl-ruby

A streaming JSON parsing and encoding library for Ruby (C bindings to yajl)
http://rdoc.info/projects/brianmario/yajl-ruby
MIT License
1.48k stars 169 forks source link

lexical error: invalid char in json text #186

Open Sunil1993 opened 6 years ago

Sunil1993 commented 6 years ago

Trying to parse large json files using yajl.

The code is working great in my local system. But when deployed in production I am getting 400 HTTP bad request. The file is coming from amazon s3.

Not sure of the exact issue here. Is it because of some authentication or wrong credentials?

Code:

require 'yajl'
require 'yajl/deflate'
require 'yajl/http_stream'
require 'uri'

uri = URI.parse(<amazon s3 link>)
hash = Yajl::HttpStream.get(uri, { headers: {"Content-Type" => "application/json", "Accept" => "application/json"}}) 

Error:

Yajl::ParseError: lexical error: invalid char in json text.
          "2018-01-08T16:04:38Z"   } ] HTTP/1.1 400 Bad Request  Date:
                     (right here) ------^

Any help would be appreciated.