Skip to main content

jsonhome

Helpers for handling jsonhome documents

Introduction

The jsonhome library provides a simple way to build and consume compliant json-home documents.

Building

To build a jsonhome document you create a document and then add resources:

>>> import jsonhome

>>> doc = jsonhome.Document()

>>> doc.add_resource('http://mysite.com/rel/widgets',
...                  uri='/widgets{/widget_id}'
...                  uri_vars={'widget_id': 'http://mysite.com/param/widget'},
...                  allow_get=True,
...                  accept_post=['application/json'])

>>> print(doc.to_json())
{
    "resources": {
        "http://mysite.com/rel/widgets": {
            "href-template": "/widgets{/widget_id}",
            "href-vars": {
                "widget_id": "http://mysite.com/param/widget"
            },
            "hints": {
                "accept-post": [
                    "application/json"
                ],
                "allow": [
                    "GET",
                    "POST"
                ]
            }
        }
    }
}

Additional parameters to creating resources can be found on the module documentation.

Consuming

To consume a json-home document you load it and then fetch the URIs you need:

>>> doc = jsonhome.Document.from_json(data)

>>> print(doc.get_uri('http://mysite.com/rel/widgets', widget_id='1234')
'/widgets/1234'

Or for specific information you can find helpers on the resource:

>>> print(doc['http://mysite.com/rel/widgets'].href_vars)
{"widget_id": "http://mysite.com/param/widget"}

Metadata

Release files for jsonhome 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsonhome 0.1.0
File Size Uploaded
jsonhome-0.1.0.tar.gz 15.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jsonhome 0.1.0
File Interpreter ABI Platform
jsonhome-0.1.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 28.6 kB

Release files / jsonhome-0.1.0.tar.gz

Download URL jsonhome-0.1.0.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d0c2e04fd77a176acb7587b49a6275f75bee73d44f717690f39f2aa57f29f015
BLAKE2b-256 checksum
How to use checksums
5a3a76ba53800e514a9867df415460b38ef4b3f7ea7769f811fdcaa07d3c2faa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / jsonhome-0.1.0-py2.py3-none-any.whl

Download URL jsonhome-0.1.0-py2.py3-none-any.whl
Size 12.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
36201a336ad96f6f07c44fb375c327176d8e0e2b5d35be145ba3c83cd564b9c5
BLAKE2b-256 checksum
How to use checksums
1f08737cc043fbd4b7e6d212474deb374edc80b0f60bd9ff343cc24dcfa02e27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.0.post8

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page