All Projects → noplay → json-api-doc

noplay / json-api-doc

Licence: other
JSON API parser returning a simple Python dictionary

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Labels

Projects that are alternatives of or similar to json-api-doc

Jsonapi Utils
Build JSON API-compliant APIs on Rails with no (or less) learning curve.
Stars: ✭ 191 (+695.83%)
Mutual labels:  jsonapi
FSharp.JsonApi
Use F# to create and consume flexible, strongly typed web APIs following the JSON:API specification
Stars: ✭ 20 (-16.67%)
Mutual labels:  jsonapi
laravel5-hal-json
Laravel 5 HAL+JSON API Transformer Package
Stars: ✭ 15 (-37.5%)
Mutual labels:  jsonapi
Waterwheel.js
A generic JavaScript helper library to query and manipulate Drupal 8 via core REST and JSON API
Stars: ✭ 237 (+887.5%)
Mutual labels:  jsonapi
jsonapi-serializable
Conveniently build and efficiently render JSON API resources.
Stars: ✭ 43 (+79.17%)
Mutual labels:  jsonapi
market place api 6
Code example of API on Rails 6 book https://github.com/madeindjs/api_on_rails
Stars: ✭ 18 (-25%)
Mutual labels:  jsonapi
Core
The server component of API Platform: hypermedia and GraphQL APIs in minutes
Stars: ✭ 2,004 (+8250%)
Mutual labels:  jsonapi
php-json-schema-model-generator
Creates (immutable) PHP model classes from JSON-Schema files including all validation rules as PHP code
Stars: ✭ 36 (+50%)
Mutual labels:  jsonapi
fire
An idiomatic micro-framework for building Ember.js compatible APIs with Go.
Stars: ✭ 56 (+133.33%)
Mutual labels:  jsonapi
jsonapi-serializer-formats
💎 Gem to enrich jsonapi-serializer with multiple formats
Stars: ✭ 20 (-16.67%)
Mutual labels:  jsonapi
Jsonapi Rails
Rails gem for fast jsonapi-compliant APIs.
Stars: ✭ 242 (+908.33%)
Mutual labels:  jsonapi
php-serializer
Serialize PHP variables, including objects, in any format. Support to unserialize it too.
Stars: ✭ 47 (+95.83%)
Mutual labels:  jsonapi
jsonapi-client
A convenient module to consume a jsonapi service
Stars: ✭ 38 (+58.33%)
Mutual labels:  jsonapi
Jsonapi Rb
Efficiently produce and consume JSON API documents.
Stars: ✭ 219 (+812.5%)
Mutual labels:  jsonapi
ember-custom-actions
Custom API actions for Ember applications
Stars: ✭ 73 (+204.17%)
Mutual labels:  jsonapi
Json Api
Implementation of JSON API in PHP 7
Stars: ✭ 171 (+612.5%)
Mutual labels:  jsonapi
JSONAPISerializer
JSONAPISerializer for Server Side Swift
Stars: ✭ 21 (-12.5%)
Mutual labels:  jsonapi
kurier
TypeScript framework to create JSON:API compliant APIs
Stars: ✭ 30 (+25%)
Mutual labels:  jsonapi
json-api-serializer
Node.js/browser framework agnostic JSON API (http://jsonapi.org/) serializer.
Stars: ✭ 141 (+487.5%)
Mutual labels:  jsonapi
json-server
Create a dummy REST API from a json file with zero coding in seconds
Stars: ✭ 34 (+41.67%)
Mutual labels:  jsonapi

JSON API Doc

Documentation Status Updates

This library provides ability to transform between normalized JSON API (http://jsonapi.org/) documents and denormalized Python dictionary object for easier manipulation in code. Also available as a command line utility and Python 3 module.

Deserialization

For this JSON API document:

{
  "data": [{
    "type": "articles",
    "id": "1",
    "attributes": {
      "title": "JSON API paints my bikeshed!",
      "body": "The shortest article. Ever.",
      "created": "2015-05-22T14:56:29.000Z",
      "updated": "2015-05-22T14:56:28.000Z"
    },
    "relationships": {
      "author": {
        "data": {"id": "42", "type": "people"}
      }
    }
  }],
  "included": [
    {
      "type": "people",
      "id": "42",
      "attributes": {
        "name": "John",
        "age": 80,
        "gender": "male"
      }
    }
  ]
}

The simplified version will be:

[
    {
        "type": "articles",
        "id": "1",
        "title": "JSON API paints my bikeshed!",
        "body": "The shortest article. Ever.",
        "created": "2015-05-22T14:56:29.000Z",
        "updated": "2015-05-22T14:56:28.000Z",
        "author": {
            "type": "people",
            "id": "42",
            "name": "John",
            "age": 80,
            "gender": "male"
        }
    }
]

Serialization

To turn an dict into JSON API specification document the root of your object must contain a $type key with a value corresponding to the name of the object's resource type. Any sub-dict or sub-array of dicts that also contain a $type key will be considered an included documents and serialized accordingly.

[
    {
        "$type": "articles",
        "id": "1",
        "title": "JSON API paints my bikeshed!",
        "body": "The shortest article. Ever.",
        "created": "2015-05-22T14:56:29.000Z",
        "updated": "2015-05-22T14:56:28.000Z",
        "author": {
            "$type": "people",
            "id": "42",
            "name": "John",
            "age": 80,
            "gender": "male"
        }
    }
]
{
  "data": [{
    "type": "articles",
    "id": "1",
    "attributes": {
      "title": "JSON API paints my bikeshed!",
      "body": "The shortest article. Ever.",
      "created": "2015-05-22T14:56:29.000Z",
      "updated": "2015-05-22T14:56:28.000Z"
    },
    "relationships": {
      "author": {
        "data": {"id": "42", "type": "people"}
      }
    }
  }],
  "included": [
    {
      "type": "people",
      "id": "42",
      "attributes": {
        "name": "John",
        "age": 80,
        "gender": "male"
      }
    }
  ]
}

Usage as python module

import json_api_doc

document =  {
    'data': {
        'type': 'article',
        'id': '1',
        'attributes': {
            'name': 'Article 1'
        }
    }
}
json_api_doc.deserialize(document)
import json_api_doc

document =  {
  '$type': 'article',
  'id': '1',
  'name': 'Article 1'
}
json_api_doc.serialize(document)

Usage as cli

$ jsonapidoc document.json

Contributors

Licence

Free software: Apache Software License 2.0

Documentation

Full Documentation is available: https://json-api-doc.readthedocs.io.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].