No commit activity in last 3 years
No release in over 3 years
Simple json api normalizer
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2.0
 Project Readme

JsonApiNormalizer

A simple way to convert datasets based on JSON API specification

Installation

Add this line to your application's Gemfile:

gem 'json_api_normalizer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install json_api_normalizer

Usage

require 'json'
require 'json_api_normalizer'

json = JSON.parse(File.read('articles.json'))
data = JsonApiNormalizer.parse(json)
puts JSON.pretty_generate(data) # =>
{
  "id": "1",
  "title": "JSON API paints my bikeshed!",
  "author": {
    "id": "9",
    "first-name": "Dan",
    "last-name": "Gebhardt",
    "twitter": "dgeb"
  },
  "comments": [
    {
      "id": "5",
      "body": "First!",
      "author": {
        "id": "2",
        "first-name": "John",
        "last-name": "Travolta",
        "twitter": "johnt"
      }
    },
    {
      "id": "12",
      "body": "I like XML better",
      "author": {
        "id": "9",
        "first-name": "Dan",
        "last-name": "Gebhardt",
        "twitter": "dgeb"
      }
    }
  ]
}

Contributing

  • Fork the project.
  • Add a breaking test for your change.
  • Make the tests pass.
  • Run rubocop -a
  • Push your fork.
  • Submit a pull request.

License

The gem is available as open source under the terms of the MIT License.