Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Git-JSON-Tree

https://img.shields.io/travis/jirikuncar/git-json-tree.svg https://img.shields.io/coveralls/jirikuncar/git-json-tree.svg https://img.shields.io/github/tag/jirikuncar/git-json-tree.svg Documentation Status https://img.shields.io/github/license/jirikuncar/git-json-tree.svg

Encode and decode JSON files as Git tree objects.

This is an experimental developer preview release.

Installation

The latest release is available on PyPI and can be installed using pip:

$ pip install git-json-tree

The development version can be installed directly from the Git repository:

$ pip install -e git+https://github.com/jirikuncar/git-json-tree.git#egg=git-json-tree

Integration with Git

Move to a repository where you would like to store JSON files and add following lines to files:

.git/config

[filter "git-json-tree"]
    smudge = "git-json-tree smudge"
    clean = "git-json-tree clean"
    required  # optional

.gitattributes

*.json  filter=git-json-tree

Pointer file format

Git Git-JSON-Tree’s pointer file looks like this:

version https://github.com/jirikuncar/git-json-tree/tree/v1
oid sha1:2f769492d6b634b86b82e916630da8a693e9c20e
size 12345

It tracks the version of Git-JSON-Tree you’re using, followed by a unique identifier for the JSON file (oid). It also stores the size of the target JSON file.

NOTE:

size is calculated from the encoded JSON string and it might differ depending on the version of serializer.

Use the command line

Interaction with the storage can also take place via the command-line interface (CLI).

First, you need to make sure that you are in a Git repository or you know its location. The example shows a case when you are in the directory with a Git repository.

$ echo '{"hello": "world", "version": 1}' | git-json-tree encode
7123db01ad8c75a8df3508305bd891317ea36feb

Following the above example you can create a first commit of your JSON object.

$ export FIRST=$(git commit-tree 7123db01 -m First)

It is quite impractical to remember tree or commit sha1, hence we can give it a reference name. The next steps uses the name master, but you can decide to use your own naming convention for tracking versions of your objects. Each file can have its own branch or just a single tag.

$ git update-ref refs/heads/master $FIRST  # for new object

Storing a new version is very simple too.

$ export PARENT=$(git show-ref --hash refs/heads/master)
$ echo '{"hello": "world", "version": 2}' | git-json-tree encode
6f36c4272e88b14ab5e25a5419599534504c70fc
$ export SECOND=$(git commit-tree 6f36c4272e -m Second -p $PARENT)
$ git update-ref refs/heads/master $SECOND

Finally, you can retrive and decode a tree or commit.

$ git-json-tree decode  # HEAD
$ git-json-tree decode $FIRST  # commit
$ git-json-tree decode 7123db01  # tree id

Metadata

Release files for git-json-tree 0.1.0.dev20180121

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

Source distribution (sdist)

Source distribution for git-json-tree 0.1.0.dev20180121
File Size Uploaded
git-json-tree-0.1.0.dev20180121.tar.gz 9.4 kB Details

Built distribution (wheel)

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

Total release size: 17.4 kB

Release files / git-json-tree-0.1.0.dev20180121.tar.gz

Download URL git-json-tree-0.1.0.dev20180121.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fe8af71e409bc026c27fc280dc674dae0bf9269686cf5498784b1bbb856abdca
BLAKE2b-256 checksum
How to use checksums
91dad2fe888b70e920f9e0205ff689a1f346df5be10cf0f32a89befc055b3df3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / git_json_tree-0.1.0.dev20180121-py2.py3-none-any.whl

Download URL git_json_tree-0.1.0.dev20180121-py2.py3-none-any.whl
Size 8.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
62478f3b74fbfb901433340488fc056bcf2dcfd3949d8f33573171f809feca09
BLAKE2b-256 checksum
How to use checksums
6a43f6efb6749ed53b9895503408957a617cdb6c97ee31782c9b7a50cd83d77d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
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