Skip to main content

A versioned JSON export utility with hash tracking

Project description

# af_json_teach

A lightweight Python utility for exporting JSON data with automatic versioning and hash tracking.  
Ideal for saving snapshots, comparing changes, and ensuring data integrity.

## Features

- Save JSON data with an auto-generated hash (SHA256)
- Track version history of JSON documents
- Load and compare different versions
- Simple API for teaching and small projects

## Installation

```bash
pip install af_json_teach

Quick Start

from af_json_teach import JSONVersioner

# Create a versioner instance (uses a local sqlite database)
jv = JSONVersioner("my_data.json")

# Save a JSON object – automatically stores hash and timestamp
jv.save({"name": "Alice", "score": 100})

# Load the latest version
data = jv.load()
print(data)

# List all versions with timestamps
versions = jv.list_versions()
print(versions)

# Compare two versions
diff = jv.diff(version1=1, version2=2)

API Reference

JSONVersioner(file_path: str, db_path: str = "versions.db")

  • save(data: dict) -> str – saves data, returns the hash
  • load(version: int = None) -> dict – loads the latest or a specific version
  • list_versions() -> List[dict] – returns list of versions with metadata
  • diff(version1: int, version2: int) -> dict – shows differences between two versions

Requirements

  • Python >= 3.6
  • No external dependencies (uses standard library only)

License

MIT License

Author

Abbas Faramarzi – GitHub

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

af_json_teach-0.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

af_json_teach-0.1.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file af_json_teach-0.1.0.tar.gz.

File metadata

  • Download URL: af_json_teach-0.1.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for af_json_teach-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e83be7554931b4beb7b0d07ffe724d14630dbf13e95d9b4165957cc6fd560202
MD5 8485480a6a49fdd37ff4838fd895323c
BLAKE2b-256 522a39be96f83a98a18e94557ab7569472d7255a2fd601a560165107b6a02a0e

See more details on using hashes here.

File details

Details for the file af_json_teach-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: af_json_teach-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for af_json_teach-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b59b0582a01ddea313194a637f890f8f1bb8c835d06ab3884780c7931adc1ef6
MD5 be9eb438903b01c0df0bc3a659a0082a
BLAKE2b-256 a1623202888eb74ede067687c3d570b37e7fbb6d291380f982426a0b47c81ba8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page