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

FYI: stock JSON middleware can return OpenStruct #3

Open
whatcould opened this issue Sep 28, 2018 · 0 comments
Open

FYI: stock JSON middleware can return OpenStruct #3

whatcould opened this issue Sep 28, 2018 · 0 comments

Comments

@whatcould
Copy link

whatcould commented Sep 28, 2018

FYI, you can now pass parser_options to the stock Faraday middleware json parser; if you tell the JSON parser to return an OpenStruct object, it will function just like this adapter. [See https://github.com/lostisland/faraday_middleware/wiki/Parsing-responses ]

connection = Faraday.new do |builder|
  builder.response :json, :content_type => /\bjson$/, parser_options: { object_class: OpenStruct }
  builder.adapter  Faraday.default_adapter
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant