add possibility to just use a parser on a per call basis #35

Merged
merged 1 commit into from Apr 17, 2012

Projects

None yet

2 participants

Contributor
phoet commented Mar 2, 2012

No description provided.

Owner
mbleigh commented Mar 16, 2012

What's the use case of per-call JSON? I'm not aware of considerations that would vary within the same app...

Contributor
phoet commented Mar 16, 2012

we are using couch_potato and tire in our application. couch_potato uses JSON.create_id = 'ruby_class' to store the type of documents in the couch. tire on the other hand uses the ruby_class attribute in an incompatibile way to store index metadata. so currently we are swapping the json engine for specific calls like this:

    def state
      # WORKAROUND (ps) json-gem in combination with JSON.create_id = 'ruby_class' fails in here
      engine = MultiJson.engine
      MultiJson.engine = :yajl
      @response = Tire::Configuration.client.get("#{Tire::Configuration.url}/_cluster/state")
      MultiJson.decode(@response.body)
    ensure
      MultiJson.engine = engine
    end

i know that we could also use the Yajl::Parser directly, but i thought it would be neat to do it on a per call basis.

Owner
mbleigh commented Mar 16, 2012

That makes sense, and an :engine option seems to be the right way to do it. Can you update your fork to be compatible with the latest HEAD?

Contributor
phoet commented Mar 16, 2012

hope i resolved the conflicts properly :]

Contributor
phoet commented Apr 16, 2012

@mbleigh do you still want to pull this?

Owner
mbleigh commented Apr 16, 2012

Yes I do, can you fix it to latest once more? Sorry for the delay.

Contributor
phoet commented Apr 16, 2012

started from scratch on latest master

@mbleigh mbleigh merged commit 25b8deb into intridea:master Apr 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment