frodenas/cloudfoundry-client — pull request #1 by krobertson (2012-01-27 17:12:09+00:00)
Title: Fix for symbolizing responses when yajl-ruby is used for JSON

This is to fix an issue with symbolizing the response keys when using the yajl-ruby gem to handle JSON. The json and yajl gems are not 100% compatible in terms of API. One main difference is on `JSON.parse`, the standard json gem takes a `:symbolize_names` option while yajl takes `:symbolize_keys`. There already is a ticket on the yajl ruby gem to make it play nice with the json gem:

https://github.com/brianmario/yajl-ruby/issues/94

But it doesn't even have a comment yet. Luckily, both params can be passed to either gem and have it function as desired:

``` ruby
string = '{"bla": "blub"}'

require 'json'
JSON.parse string, :symbolize_names => true # => {:bla=>"blub"}
JSON.parse string, :symbolize_keys => true # => {"bla"=>"blub"}
JSON.parse string, :symbolize_keys => true, :symbolize_names => true # => {:bla:=>"blub"}

require 'yajl/json_gem'
JSON.parse string, :symbolize_names => true # => {"bla"=>"blub"}
JSON.parse string, :symbolize_keys => true # => {:bla=>"blub"}
JSON.parse string, :symbolize_keys => true, :symbolize_names => true # => {:bla=>"blub"}
```

This patch ensures that both options are passed to `JSON.parse`.