Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


WebMock::Util::JSON.parse fails for binary strings. #260

wants to merge 1 commit into from

2 participants

Levin Alexander Bartosz Blimke
Levin Alexander

Webmock includes its own JSON parser. Turns out it doesn't parse some valid JSON strings.

What's a good way to proceed here? Should I try to fix the JSON parser or would it be better to include a JSON dependency?

Levin Alexander

On further reflection: binary strings are not valid JSON. This is not a bug.

Levin Alexander levinalex closed this
Bartosz Blimke

As you can see in the header of lib/webmock/util.json.rb it's a copied parser from Crack with date parsing removed. I don't mind updating it to the latest version from Crack (with date parsing removed :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 7, 2013
  1. Levin Alexander
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 1 deletion.
  1. +5 −1 spec/unit/util/json_spec.rb
6 spec/unit/util/json_spec.rb
@@ -4,4 +4,8 @@
it "should parse json without parsing dates" do
WebMock::Util::JSON.parse("\"a\":\"2011-01-01\"").should == {"a" => "2011-01-01"}
+ it "should parse json that includes binary strings" do
+ WebMock::Util::JSON.parse("{\"a\":\"\\u0000\\u0001\\u0002\"}").should == {"a" => "\x00\x01\x02"}
+ end
Something went wrong with that request. Please try again.