https://github.com/g13ydson/json_api_query_parser
Parse JSON API endpoint and its query parameters to a usable Hash
https://github.com/g13ydson/json_api_query_parser
fast json-api json-parser rails
Last synced: 4 months ago
JSON representation
Parse JSON API endpoint and its query parameters to a usable Hash
- Host: GitHub
- URL: https://github.com/g13ydson/json_api_query_parser
- Owner: g13ydson
- License: mit
- Created: 2018-06-28T11:21:51.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-15T12:38:58.000Z (over 7 years ago)
- Last Synced: 2025-11-08T08:19:12.636Z (7 months ago)
- Topics: fast, json-api, json-parser, rails
- Language: Ruby
- Homepage:
- Size: 19.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# JSON API query parser
[](https://badge.fury.io/rb/json_api_query_parser) [](https://travis-ci.org/g13ydson/json_api_query_parser) [](https://codeclimate.com/github/g13ydson/json_api_query_parser/maintainability) [](https://codeclimate.com/github/g13ydson/json_api_query_parser/test_coverage)
To be used for ruby projects that make use of [JSON API](http://jsonapi.org/)
## Installation
```sh
$ gem install json_api_query_parser
```
Or in the gemfile of the rails project
```ruby
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.
```ruby
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.
```ruby
{
:resource_type=>"movies",
:identifier=>"5",
:query_data=>{
:include=>["actors", "actors.agency"],
:fields=>{:movies=>["title", "year"], :actors=>["name"]},
:page=>{"limit"=>"20"}
}
}
```