No commit activity in last 3 years
No release in over 3 years
Parse JSON API endpoint and its query parameters to a usable Hash
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 10.0
~> 3.0
 Project Readme

JSON API query parser

Gem Version Build Status Maintainability Test Coverage

To be used for ruby projects that make use of JSON API

Installation

$ gem install json_api_query_parser

Or in the gemfile of the rails project

gem 'json_api_query_parser'

Usage

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")

Return data information

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"}
  }
}