Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for more XML and JSON parsing libraries #4

Open
metavida opened this issue Oct 14, 2010 · 4 comments
Open

Add support for more XML and JSON parsing libraries #4

metavida opened this issue Oct 14, 2010 · 4 comments
Labels

Comments

@metavida
Copy link
Collaborator

The ruby-oembed gem currently relies on the xml-simple and json gems. It should allow for other parsing libraries to be either detected or specified. Libraries we should support:

XML

  • Hpricot
  • Nokogiri

JSON

  • Rails 3 JSON

Sugest even more in the comments.

@metavida
Copy link
Collaborator Author

Nokogiri & ActiveSupport::JSON are both covered. So close to closing this one!

@hmans
Copy link
Contributor

hmans commented Jan 11, 2017

Hey @metavida, how about Oj? (I'm happy to have a stab at adding this.)

I'm using ruby-oembed in a non-Rails project right now, and it's failing with many JSON responses (esp. those coming from Twitter, but I haven't seen a clear pattern) unless I specifically require active_support/json, which I'm not terribly keen on doing.

@metavida
Copy link
Collaborator Author

Hi @hmans,

Have you tried using the json gem instead of ActiveSupport's JSON? Either require "json" before you require ruby-oembed or call OEmbed::Formatter::JSON.backend = 'JSONGem'

I likely won't have time to implement support for Oj, but would be glad to review & merge in a pull request if you send one! You can use this class as inspiration. Really all you'll need is three public class methods! You can even start using your custom JSON formatter before I've officially merged it:

class MyOjFormatter
  ...
end

OEmbed::Formatter::JSON.backend = MyOjFormatter

Hope this helps!
--Marcos

@hmans
Copy link
Contributor

hmans commented Jan 12, 2017

Thanks for the heads-up!

I tried loading the json gem before loading ruby-oembed and got mixed results unfortunately -- I haven't had much luck in tracking down why this was, but it did work at some point, and then stopped. It's good to know that I can set the backend explicitly, I will try that next. Otherwise, maybe I'll find some time to cram Oj in there soon.

Thanks, and keep up the good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants