dag-json


Namedag-json JSON
Version 0.1 PyPI version JSON
download
home_page
SummaryPython implemention of the IPLD DAG-JSON codec
upload_time2023-04-23 23:38:41
maintainer
docs_urlNone
author
requires_python>=3.7
license
keywords dag-json ipld codec cid
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            dag-json [![Circle CI](https://circleci.com/gh/snarfed/dag-json.svg?style=svg)](https://circleci.com/gh/snarfed/dag-json) [![Coverage Status](https://coveralls.io/repos/github/snarfed/dag-json/badge.svg?branch=main)](https://coveralls.io/github/snarfed/dag-json?branch=master)
===

Python implemention of the [IPLD](https://ipld.io/) [DAG-JSON codec](https://ipld.io/docs/codecs/known/dag-json/). Uses the `CID` class from [`multiformats`](https://multiformats.readthedocs.io/). Passes all of IPLD's [DAG-JSON cross-codec test fixtures](https://ipld.io/specs/codecs/dag-json/fixtures/cross-codec/).

Install from [PyPI](https://pypi.org/project/dag-json/) with `pip install dag-json`.

License: This project is placed in the public domain.

* [Usage](#usage)
* [Changelog](#changelog)
* [Release instructions](#release-instructions)


## Usage

The `dag_json` module has two functions, `encode` and `decode`.
* `encode` takes any IPLD-compatible native Python object - `int`, `float`, `str`, `bool`, `list`, `bytes`, or `multiformats.CID` - and returns it as DAG-JSON encoded `bytes`.
* `decode` takes DAG-JSON encoded `bytes` and returns the corresponding native Python object.

Here's example usage:

```py
>>> from dag_json import decode, encode
>>> from multiformats import CID
>>>
>>> encoded = encode({
    'foo': 'bar',
    'data': b'hello world',
    'link': CID.decode('QmUGhP2X8xo9dsj45vqx1H6i5WqPqLqmLQsHTTxd3ke8mp'),
})
>>> encoded
b'{"data":{"/":{"bytes":"aGVsbG8gd29ybGQ"}},"foo":"bar","link":{"/":"QmUGhP2X8xo9dsj45vqx1H6i5WqPqLqmLQsHTTxd3ke8mp"}}'
>>>
>>> repr(decode(encoded))
{
    'data': b'hello world',
    'foo': 'bar',
    'link': CID('base58btc', 0, 'dag-pb', '12205822d187bd40b04cc8ae7437888ebf844efac1729e098c8816d585d0fcc42b5b'),
}
```


## Changelog

### 0.1 - 2023-04-23

Initial release!


## Release instructions

Here's how to package, test, and ship a new release.

1. Run the unit tests.

    ```sh
    source local/bin/activate.csh
    python3 -m unittest discover
    ```
1. Bump the version number in `pyproject.toml`. `git grep` the old version number to make sure it only appears in the changelog. Change the current changelog entry in `README.md` for this new version from _unreleased_ to the current date.
1. `git commit -am 'release vX.Y'`
1. Upload to [test.pypi.org](https://test.pypi.org/) for testing.

    ```sh
    python3 -m build
    setenv ver X.Y
    twine upload -r pypitest dist/dag-json-$ver*
    ```
1. Install from test.pypi.org.

    ```sh
    cd /tmp
    python3 -m venv local
    source local/bin/activate.csh
    pip3 uninstall dag-json # make sure we force pip to use the uploaded version
    pip3 install --upgrade pip
    pip3 install -i https://test.pypi.org/simple --extra-index-url https://pypi.org/simple dag-json==$ver
    deactivate
    ```
1. [Run the example code above](#usage) to test that the code loads and runs.
1. Tag the release in git. In the tag message editor, delete the generated comments at bottom, leave the first line blank (to omit the release "title" in github), put `### Notable changes` on the second line, then copy and paste this version's changelog contents below it.

    ```sh
    git tag -a v$ver --cleanup=verbatim
    git push && git push --tags
    ```
1. [Click here to draft a new release on GitHub.](https://github.com/snarfed/dag-json/releases/new) Enter `vX.Y` in the _Tag version_ box. Leave _Release title_ empty. Copy `### Notable changes` and the changelog contents into the description text box.
1. Upload to [pypi.org](https://pypi.org/)!

    ```sh
    twine upload dist/dag-json-$ver.tar.gz dist/dag-json-$ver-py3-none-any.whl
    ```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "dag-json",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "DAG-JSON,IPLD,codec,CID",
    "author": "",
    "author_email": "Ryan Barrett <dag-json@ryanb.org>",
    "download_url": "https://files.pythonhosted.org/packages/52/30/08d8dc74c73188e72a4c1f826b47df9544e5c3a652e6331374d44fca4e24/dag-json-0.1.tar.gz",
    "platform": null,
    "description": "dag-json [![Circle CI](https://circleci.com/gh/snarfed/dag-json.svg?style=svg)](https://circleci.com/gh/snarfed/dag-json) [![Coverage Status](https://coveralls.io/repos/github/snarfed/dag-json/badge.svg?branch=main)](https://coveralls.io/github/snarfed/dag-json?branch=master)\n===\n\nPython implemention of the [IPLD](https://ipld.io/) [DAG-JSON codec](https://ipld.io/docs/codecs/known/dag-json/). Uses the `CID` class from [`multiformats`](https://multiformats.readthedocs.io/). Passes all of IPLD's [DAG-JSON cross-codec test fixtures](https://ipld.io/specs/codecs/dag-json/fixtures/cross-codec/).\n\nInstall from [PyPI](https://pypi.org/project/dag-json/) with `pip install dag-json`.\n\nLicense: This project is placed in the public domain.\n\n* [Usage](#usage)\n* [Changelog](#changelog)\n* [Release instructions](#release-instructions)\n\n\n## Usage\n\nThe `dag_json` module has two functions, `encode` and `decode`.\n* `encode` takes any IPLD-compatible native Python object - `int`, `float`, `str`, `bool`, `list`, `bytes`, or `multiformats.CID` - and returns it as DAG-JSON encoded `bytes`.\n* `decode` takes DAG-JSON encoded `bytes` and returns the corresponding native Python object.\n\nHere's example usage:\n\n```py\n>>> from dag_json import decode, encode\n>>> from multiformats import CID\n>>>\n>>> encoded = encode({\n    'foo': 'bar',\n    'data': b'hello world',\n    'link': CID.decode('QmUGhP2X8xo9dsj45vqx1H6i5WqPqLqmLQsHTTxd3ke8mp'),\n})\n>>> encoded\nb'{\"data\":{\"/\":{\"bytes\":\"aGVsbG8gd29ybGQ\"}},\"foo\":\"bar\",\"link\":{\"/\":\"QmUGhP2X8xo9dsj45vqx1H6i5WqPqLqmLQsHTTxd3ke8mp\"}}'\n>>>\n>>> repr(decode(encoded))\n{\n    'data': b'hello world',\n    'foo': 'bar',\n    'link': CID('base58btc', 0, 'dag-pb', '12205822d187bd40b04cc8ae7437888ebf844efac1729e098c8816d585d0fcc42b5b'),\n}\n```\n\n\n## Changelog\n\n### 0.1 - 2023-04-23\n\nInitial release!\n\n\n## Release instructions\n\nHere's how to package, test, and ship a new release.\n\n1. Run the unit tests.\n\n    ```sh\n    source local/bin/activate.csh\n    python3 -m unittest discover\n    ```\n1. Bump the version number in `pyproject.toml`. `git grep` the old version number to make sure it only appears in the changelog. Change the current changelog entry in `README.md` for this new version from _unreleased_ to the current date.\n1. `git commit -am 'release vX.Y'`\n1. Upload to [test.pypi.org](https://test.pypi.org/) for testing.\n\n    ```sh\n    python3 -m build\n    setenv ver X.Y\n    twine upload -r pypitest dist/dag-json-$ver*\n    ```\n1. Install from test.pypi.org.\n\n    ```sh\n    cd /tmp\n    python3 -m venv local\n    source local/bin/activate.csh\n    pip3 uninstall dag-json # make sure we force pip to use the uploaded version\n    pip3 install --upgrade pip\n    pip3 install -i https://test.pypi.org/simple --extra-index-url https://pypi.org/simple dag-json==$ver\n    deactivate\n    ```\n1. [Run the example code above](#usage) to test that the code loads and runs.\n1. Tag the release in git. In the tag message editor, delete the generated comments at bottom, leave the first line blank (to omit the release \"title\" in github), put `### Notable changes` on the second line, then copy and paste this version's changelog contents below it.\n\n    ```sh\n    git tag -a v$ver --cleanup=verbatim\n    git push && git push --tags\n    ```\n1. [Click here to draft a new release on GitHub.](https://github.com/snarfed/dag-json/releases/new) Enter `vX.Y` in the _Tag version_ box. Leave _Release title_ empty. Copy `### Notable changes` and the changelog contents into the description text box.\n1. Upload to [pypi.org](https://pypi.org/)!\n\n    ```sh\n    twine upload dist/dag-json-$ver.tar.gz dist/dag-json-$ver-py3-none-any.whl\n    ```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python implemention of the IPLD DAG-JSON codec",
    "version": "0.1",
    "project_urls": null,
    "split_keywords": [
        "dag-json",
        "ipld",
        "codec",
        "cid"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "26877b2451240dd78e2462f8cc800567f8f13a1c63b156f521653c7a1dd4a0ca",
                "md5": "84b037ad6bd366543e34dbd7beadd60b",
                "sha256": "a2048fabc9e882fea8595dbeb0c56454600c559a737fa2f178df48f67233ca1f"
            },
            "downloads": -1,
            "filename": "dag_json-0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "84b037ad6bd366543e34dbd7beadd60b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 3882,
            "upload_time": "2023-04-23T23:38:38",
            "upload_time_iso_8601": "2023-04-23T23:38:38.904562Z",
            "url": "https://files.pythonhosted.org/packages/26/87/7b2451240dd78e2462f8cc800567f8f13a1c63b156f521653c7a1dd4a0ca/dag_json-0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "523008d8dc74c73188e72a4c1f826b47df9544e5c3a652e6331374d44fca4e24",
                "md5": "fd9fd66335d33584306306022f24c7d5",
                "sha256": "93992b3c31eddb2fe5598715c9b46301cc4a203cc95735b9bdc510de5df1a5f5"
            },
            "downloads": -1,
            "filename": "dag-json-0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "fd9fd66335d33584306306022f24c7d5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 3877,
            "upload_time": "2023-04-23T23:38:41",
            "upload_time_iso_8601": "2023-04-23T23:38:41.521290Z",
            "url": "https://files.pythonhosted.org/packages/52/30/08d8dc74c73188e72a4c1f826b47df9544e5c3a652e6331374d44fca4e24/dag-json-0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-23 23:38:41",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "dag-json"
}
        
Elapsed time: 0.25296s