Skip to main content


EasyJSON
JsonIO

🚀 Seamless JSON Handling in Python 🐍

Created At Last Commit MIT License

Overview • Features • Installation • Documentation • Usage • Contributions • License

Overview

JsonIO is a high-level API for handling JSON serialization and deserialization in Python using the orjson library. It provides a simple and efficient way to work with JSON data, including support for custom types.

Features

  • Fast Serialization: Built on orjson, offering high-performance JSON serialization.

  • Custom Serialization: Easily extendable to handle non-standard data types with a custom encoder.

  • Convenient File Operations: Load and save JSON data directly from/to files.

Installation

You can install the module via pip:

pip install ayrun-jsonio

Documentation

The documentation website is still under development.

Usage

Basic Functions

The module provides the following main functions:

  • loads(data: Union[str, bytes]) -> Any: Deserialize a JSON string or bytes into a Python object.

  • load(filepath: Union[str, Path]) -> Any: Read a JSON file and return the corresponding Python object.

  • dumps(obj: Any, *, option: Optional[int] = None, default: Optional[Callable[[Any], Any]] = None) -> str: Serialize a Python object into a JSON string.

  • dump(obj: Any, filepath: Union[str, Path], *, option: Optional[int] = None, default: Optional[Callable[[Any], Any]] = None) -> None: Serialize a Python object and write it to a JSON file.

Example Usage

import uuid
from datetime import datetime
from decimal import Decimal

import jsonio

# Sample data
data = {
    "name": "Alice",
    "age": 30,
    "balance": Decimal("1234.56"),  # Decimal support
    "tags": {"json", "python"},       # Set support
    "uuid": uuid.uuid4(),             # UUID support
    "timestamp": datetime.now()        # Datetime support
}

# Serialize to JSON string
json_str = jsonio.dumps(data, default=my_custom_encoder)
print(json_str)

# Deserialize from JSON string
loaded_data = jsonio.loads(json_str)
print(loaded_data)

# Save to a file
jsonio.dump(data, "data.json", default=my_custom_encoder)

# Load from a file
file_data = jsonio.load("data.json")
print(file_data)

Contributions

Contributions are welcome! Please feel free to submit a pull request or open an issue if you encounter any problems or have suggestions for improvements.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for ayrun-jsonio 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 ayrun-jsonio 0.1.0
File Size Uploaded
ayrun_jsonio-0.1.0.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ayrun-jsonio 0.1.0
File Interpreter ABI Platform
ayrun_jsonio-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.6 kB

Release files / ayrun_jsonio-0.1.0.tar.gz

Download URL ayrun_jsonio-0.1.0.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
599f86eb61ecf55cac1950a563108c46aa6f7476d8d5f0fad8e5c0cb1b18182d
BLAKE2b-256 checksum
How to use checksums
53c1635b3c1705a52dff24b12fe3f70e9864db41954e0440d07a27367740d20f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.5 Windows/11

Release files / ayrun_jsonio-0.1.0-py3-none-any.whl

Download URL ayrun_jsonio-0.1.0-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0d3c4f0dace1db9214f598910992c9eb144db7f4032aba739223c16018ee908
BLAKE2b-256 checksum
How to use checksums
88efd4e6e698a50898df6eea6f4a608124171d8a10f9808407c86636afa48710
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.5 Windows/11

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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