interagent / pliny

An opinionated toolkit for writing excellent APIs in Ruby.
MIT License
801 stars 73 forks source link

Handle a JSON Array of params #328

Closed stevenharman closed 4 years ago

stevenharman commented 4 years ago

Back in #317 we started using Sinatra::IndifferentHash for Sinatra v2+, but didn't handle the case of a JSON array being passed as the root element. The older #indifferent_params from Sinatra v1 did handle this case. We've roughly re-created that here, though we're a little more permissive in that we allow for things that are Hash-like (via #to_hash) and Array-like (via #to_ary) rather than relying on type.