Project

skalka

0.0
No commit activity in last 3 years
No release in over 3 years
Simple JSON API parser/flattener
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

Runtime

 Project Readme

Skalka

Build Status

Skalka — the rolling pin for your json api responses.

Installation

Add to Gemfile

gem "skalka"

Run bundle

bundle install

Usage

require "skalka"

json = %{
  {
    "data": [{
      "type": "articles",
      "id": "1",
      "attributes": {
        "title": "Wise Thought",
        "body": "You can't blame gravity for falling in love.",
        "created_at": "2015-05-22T14:56:29.000Z",
        "updated_at": "2015-05-22T14:56:28.000Z"
      },
      "relationships": {
        "author": {
          "data": { "id": "42", "type": "people" }
        },
        "comments": {
          "data": { "id": "55", "type": "comments" }
        }
      }
    }],
    "included": [
      {
        "type": "people",
        "id": "42",
        "attributes": {
          "name": "Albert Einstein",
          "age": 76,
          "gender": "male"
        }
      },
      {
        "type": "comments",
        "id": "55",
        "attributes": {
          "content": "Meh"
        }
      }
    ],
    "meta": {
      "page": "1",
      "count": "1"
    }
  }
}

Skalka.call(json)

{
  data: {
    id: "1",
    type: "articles",
    attributes: {
      title: "Wise Thought",
      body: "You can't blame gravity for falling in love.",
      created_at: "2015-05-22T14:56:29.000Z",
      updated_at: "2015-05-22T14:56:28.000Z",
      author: {
        id: "42",
        type: "authors",
        attributes: {
          id: "42", name: "Albert Einstein", age: 76, gender: "male"
        }
      },
      comments: [
        {
          id: "55",
          type: "comments",
          attributes: { id: "55", content: "Meh" }
        }
      ]
    }
  },
  meta: { page: "1", count: "1" }
}

Ruby support

  • 2.5.0

Credits

Skalka is built with transproc under the hood and shares its FP spirit.