7even/vkontakte_api

Yajl::ParseError: lexical error: invalid character inside string.

targence opened this issue · 3 comments

Hi

I'm trying to perform this request @app.groups.getById(gids:"23201, 23202, 23203",fields:"country,city")

It's returning error.

Yajl::ParseError: lexical error: invalid character inside string.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!","screen_name":"club23202","
(right here) ------^

from /Users/.rvm/gems/ruby-1.9.3-p0/gems/yajl-ruby-1.1.0/lib/yajl.rb:36:in `parse'
from /Users/.rvm/gems/ruby-1.9.3-p0/gems/yajl-ruby-1.1.0/lib/yajl.rb:36:in `parse'
from /Users/.rvm/gems/ruby-1.9.3-p0/gems/vkontakte_api-0.2.1/lib/vkontakte_api/api.rb:22:in `call'
from /Users/.rvm/gems/ruby-1.9.3-p0/gems/vkontakte_api-0.2.1/lib/vkontakte_api/resolver.rb:48:in `method_missing'
from (irb):11
from /Users/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'

Any idea to fix it?

Hello.

Thanks, I was just searching for the API method causing this error. @nemilya found out that VK sometimes returns JSON that Yajl cannot parse. So I'll use another parser in 1.0 version of vkontakte_api which I'm working on currently.

Just checked several parsers with this task, and only Oj succeeded, though it doesn't symbolize keys.

Do you need a quick fix for that? I don't think I'll release 1.0 in a few days so I can do a 0.3 with Oj dependency.

I've fixed the problem in 1.0 branch (by switching to Oj parser), so if you need it right now you can simply put the following in your Gemfile:

# Gemfile
gem 'vkontakte_api', github: '7even/vkontakte_api', branch: '1.0'

Thanks. It's works for me.