Comments (9)
i can confirm this issue.
here is a snippet how to reproduce it:
Loading development environment (Rails 3.0.7)
ruby-1.9.2-p180 :004 > require 'crack'
ruby-1.9.2-p180 :002 > url = 'http://picasaweb.google.com/data/feed/base/user/phoet6/?alt=json'
ruby-1.9.2-p180 :001 > HTTPClient.get(url).content
ruby-1.9.2-p180 :003 > resp = HTTPClient.get(url).content
ruby-1.9.2-p180 :005 > resp = Crack::JSON.parse(resp)
Psych::SyntaxError: couldn't parse YAML at line 1 column 395
from /Users/peterschroder/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych.rb:148:in `parse'
from /Users/peterschroder/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych.rb:148:in `parse_stream'
from /Users/peterschroder/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych.rb:119:in `parse'
from /Users/peterschroder/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych.rb:106:in `load'
from /Users/peterschroder/.rvm/gems/ruby-1.9.2-p180@basement/gems/crack-0.1.8/lib/crack/json.rb:12:in `parse'
from (irb):5
from /Users/peterschroder/.rvm/gems/ruby-1.9.2-p180@basement/gems/railties-3.0.7/lib/rails/commands/console.rb:44:in `start'
from /Users/peterschroder/.rvm/gems/ruby-1.9.2-p180@basement/gems/railties-3.0.7/lib/rails/commands/console.rb:8:in `start'
from /Users/peterschroder/.rvm/gems/ruby-1.9.2-p180@basement/gems/railties-3.0.7/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:10:in `require'
from script/rails:10:in `<main>'
from crack.
it took me some time to reproduce the issue on a second machine. at first i thought it might be a problem with the latest iMac, but i can reproduce it on my macbook too.
here is what i did:
$ rvm get head
$ rvm install 1.9.2
ruby-1.9.2-p180@basement:
system:
uname: "Darwin ernst.local 10.7.1 Darwin Kernel Version 10.7.1: Thu Jan 27 18:47:00 PST 2011; root:xnu-1504.10.48~2/RELEASE_X86_64 x86_64"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
zsh: "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"
rvm:
version: "rvm 1.6.18 by Wayne E. Seguin ([email protected]) [https://rvm.beginrescueend.com/]"
ruby:
interpreter: "ruby"
version: "1.9.2p180"
date: "2011-02-18"
platform: "x86_64-darwin10.7.1"
patchlevel: "2011-02-18 revision 30909"
full_version: "ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.1]"
homes:
gem: "/Users/peterschroder/.rvm/gems/ruby-1.9.2-p180@basement"
ruby: "/Users/peterschroder/.rvm/rubies/ruby-1.9.2-p180"
binaries:
ruby: "/Users/peterschroder/.rvm/rubies/ruby-1.9.2-p180/bin/ruby"
irb: "/Users/peterschroder/.rvm/rubies/ruby-1.9.2-p180/bin/irb"
gem: "/Users/peterschroder/.rvm/rubies/ruby-1.9.2-p180/bin/gem"
rake: "/Users/peterschroder/.rvm/gems/ruby-1.9.2-p180@global/bin/rake"
environment:
PATH: "/Users/peterschroder/.rvm/gems/ruby-1.9.2-p180@basement/bin:/Users/peterschroder/.rvm/gems/ruby-1.9.2-p180@global/bin:/Users/peterschroder/.rvm/rubies/ruby-1.9.2-p180/bin:/Users/peterschroder/.rvm/bin:/Users/peterschroder/Library/android:/Users/peterschroder/.script:/Users/peterschroder/Library/grails/bin:/Users/peterschroder/Library/groovy/bin:/Users/peterschroder/.gem/ruby/1.8/bin:/Users/peterschroder/Library/maven/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/opt/nginx/sbin"
GEM_HOME: "/Users/peterschroder/.rvm/gems/ruby-1.9.2-p180@basement"
GEM_PATH: "/Users/peterschroder/.rvm/gems/ruby-1.9.2-p180@basement:/Users/peterschroder/.rvm/gems/ruby-1.9.2-p180@global"
MY_RUBY_HOME: "/Users/peterschroder/.rvm/rubies/ruby-1.9.2-p180"
IRBRC: "/Users/peterschroder/.rvm/rubies/ruby-1.9.2-p180/.irbrc"
RUBYOPT: "rubygems"
gemset: "basement"
$ bundle --version
Bundler version 1.0.14
$ rails -v
Rails 3.0.7
Since RVM is using some YAML library during installation of 1.9.2 it might be related to that:
--no-same-owner
Configuring yaml in /Users/peterschroder/.rvm/src/yaml-0.1.3.
Compiling yaml in /Users/peterschroder/.rvm/src/yaml-0.1.3.
Installing yaml to /Users/peterschroder/.rvm/usr
from crack.
i tried a rather radical approach and removed my rvm installation and replacing it with an old/random version, but it worked out:
paule@phoet:~○$ rm -rf .rvm
paule@phoet:~○$ curl -s https://rvm.beginrescueend.com/install/rvm -o rvm-installer ; chmod +x rvm-installer ; ./rvm-installer --version 1.6.2
from crack.
I don't know the fix for rvm or crack, but this worked for me:
require 'httparty'
requre 'json'
response = HTTParty.get("http://someurl.com", :format => :plain)
JSON.parse(response.body)
It effectively ignores Crack's implementation. Not ideal, but good 'nuff for my use case.
from crack.
Adding
YAML::ENGINE.yamler = "syck"
to the top of my file fixed this for me.
from crack.
It is effectively tied to the syck versus psych issue. They don't have identical JSON parsing behavior and do not throw exactly the same errors up the stack. If, for example, you pass in HTML and ask it to parse it as if it were JSON Crack via syck will catch the error from syck and wrap it in a Crack::ParseError whereas Crack via psych will let the Psych::SyntaxError pass through.
The Psych::Syntax error type inherits from SyntaxError instead of StandardError so something like a vanilla rescue statement wouldn't catch the PsychError while it may catch a similar error condition from syck simply because it is wrapped differently.
For more information on the PsychError see the following issue: ruby/psych#23
from crack.
+1 to @sachse. I dropped that in config/initializers/httparty.rb and I'm good.
from crack.
@sachse thank you! You're making my day.
from crack.
Closing since someone suggested solution.
from crack.
Related Issues (20)
- YAML load errors when parsing JSON that initially contained a \u0000 character sequence HOT 2
- Crack treats JSON parsing errors differently depending on the underlying YAML parser HOT 1
- parsing of XML return a singleton Hash that is not dumpable HOT 4
- Xml not parsing properly HOT 1
- Add bigdecimal to gemspec HOT 1
- many json tests are failing with ruby 1.9 HOT 2
- Fails to run Jekyll 1.0.3 (conflicting versions of safe_yaml) on Mac OSX 10.8.3 HOT 1
- Support for Attributes HOT 2
- Crack::JSON is not parsing UTF-8 correctly HOT 1
- Crack::JSON can't parse valid json string with UTF-8 character
- Issue with array of elements when the key is an attribute of the nodw HOT 2
- Key mangling when using two dates HOT 1
- Crack 0.4.3 cannot parse two consecutive dates HOT 1
- Xml parsing dont return attribute of tag HOT 1
- make a 1.0.0 release? HOT 5
- Remove `test/` from bundled gem HOT 4
- Please include license file in the gem. HOT 1
- Missing v0.4.5 tag HOT 2
- JSON failures with Ruby 3.1 / Psych 4.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crack.