To be used for ruby projects that make use of JSON API
$ gem install json_api_query_parser
Or in the gemfile of the rails project
gem 'json_api_query_parser'
Require the gem 'json_api_query_parser' into your application and use the 'parse_request' method to convert the request.url to an easy usable Hash.
require('json_api_query_parser')
JsonApiQueryParser.parse_request("movies/5?include=actors,actors.agency&fields[movies]=title,year&fields[actors]=name&page[limit]=20")
The Hash returned by the JsonApiQueryParser.parse_request will always be the same structure.
{
:resource_type=>"movies",
:identifier=>"5",
:query_data=>{
:include=>["actors", "actors.agency"],
:fields=>{:movies=>["title", "year"], :actors=>["name"]},
:page=>{"limit"=>"20"}
}
}