ayrun-jsonkit


Nameayrun-jsonkit JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/ayrun3412/JSONKit
SummaryA library for enhanced JSON file handling with support for datetime and UUID objects, both synchronously and asynchronously.
upload_time2024-09-17 07:21:05
maintainerNone
docs_urlNone
authorayrun
requires_python<4.0,>=3.12
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <img src="./assets/jsonkit_logo.png" alt="JSONKit Logo"/>
</p>
<hr>
<h4 align="center">🚀 <i>Your toolkit for seamless JSON handling.</i></h4>

<p align="center">
  <a href="#️overview">Overview</a> •
  <a href="#features">Features</a> •
  <a href="#installation">Installation</a> •
  <a href="#usage">Usage</a> •
  <a href="#license">License</a> •
  <a href="#contributing">Contributing</a>
</p>

# Overview

JSONKit is a Python Library for enhanced JSON file handling with support for `datetime` and `UUID` objects. It provides both `synchronous` and `asynchronous` file operations.

## Features

- **Synchronous Operations**: Read and write JSON files with custom encoding and decoding for `datetime` and `UUID` objects.
- **Asynchronous Operations**: Handle JSON files asynchronously using `aiofiles`.
- **Custom Serialization**: Special handling for `datetime` and `UUID` types.

## Installation

You can install JSONKit via pip:

```bash
pip install ayrun-jsonkit
```

## Usage

#### Synchronous Usage:

```python
from jsonkit import JSONFile
from datetime import datetime
import uuid

# Initialize the JSONFile object
json_file = JSONFile('example.json')

# Write data to the file
data = {
    "name": "Alice",
    "age": 30,
    "created_at": datetime.now(),
    "id": uuid.uuid4()
}

# The 'write' function automatically returns the loaded data. So you can either choose to do this:
loaded_data = json_file.write(data, indent=4)
print(loaded_data)

# Or:
json_file.write(data, indent=4)
loaded_data = json_file.load()
print(loaded_data)
```

#### Asynchronous Usage:

```python
from jsonkit import AsyncJSONFile
from datetime import datetime
import uuid
import asyncio

async def main():
    # Initialize the AsyncJSONFile object
    async_json_file = AsyncJsonFile('data.json')

    # Write data to the file
    data = {
        "name": "Bob",
        "age": 25,
        "created_at": datetime.now(),
        "id": uuid.uuid4()
    }

    # The 'write' function automatically returns the loaded data. So you can either choose to do this:
    loaded_data = await async_json_file.write(data, indent=4)
    print(loaded_data)

    # Or:
    await async_json_file.write(data, indent=4)
    loaded_data = await async_json_file.load()
    print(loaded_data)

# Run the async main function
asyncio.run(main())
```

## License

JSONKit is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more details.

## Contributing

Contributions are welcome! Please open an issue or submit a pull request.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ayrun3412/JSONKit",
    "name": "ayrun-jsonkit",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.12",
    "maintainer_email": null,
    "keywords": null,
    "author": "ayrun",
    "author_email": "ayrun3412@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3d/f9/c02ed6d6df040d4758b3acfaadb5dbc8ba541c5967af389d7be7c61217c6/ayrun_jsonkit-1.1.0.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n  <img src=\"./assets/jsonkit_logo.png\" alt=\"JSONKit Logo\"/>\n</p>\n<hr>\n<h4 align=\"center\">\ud83d\ude80 <i>Your toolkit for seamless JSON handling.</i></h4>\n\n<p align=\"center\">\n  <a href=\"#\ufe0foverview\">Overview</a> \u2022\n  <a href=\"#features\">Features</a> \u2022\n  <a href=\"#installation\">Installation</a> \u2022\n  <a href=\"#usage\">Usage</a> \u2022\n  <a href=\"#license\">License</a> \u2022\n  <a href=\"#contributing\">Contributing</a>\n</p>\n\n# Overview\n\nJSONKit is a Python Library for enhanced JSON file handling with support for `datetime` and `UUID` objects. It provides both `synchronous` and `asynchronous` file operations.\n\n## Features\n\n- **Synchronous Operations**: Read and write JSON files with custom encoding and decoding for `datetime` and `UUID` objects.\n- **Asynchronous Operations**: Handle JSON files asynchronously using `aiofiles`.\n- **Custom Serialization**: Special handling for `datetime` and `UUID` types.\n\n## Installation\n\nYou can install JSONKit via pip:\n\n```bash\npip install ayrun-jsonkit\n```\n\n## Usage\n\n#### Synchronous Usage:\n\n```python\nfrom jsonkit import JSONFile\nfrom datetime import datetime\nimport uuid\n\n# Initialize the JSONFile object\njson_file = JSONFile('example.json')\n\n# Write data to the file\ndata = {\n    \"name\": \"Alice\",\n    \"age\": 30,\n    \"created_at\": datetime.now(),\n    \"id\": uuid.uuid4()\n}\n\n# The 'write' function automatically returns the loaded data. So you can either choose to do this:\nloaded_data = json_file.write(data, indent=4)\nprint(loaded_data)\n\n# Or:\njson_file.write(data, indent=4)\nloaded_data = json_file.load()\nprint(loaded_data)\n```\n\n#### Asynchronous Usage:\n\n```python\nfrom jsonkit import AsyncJSONFile\nfrom datetime import datetime\nimport uuid\nimport asyncio\n\nasync def main():\n    # Initialize the AsyncJSONFile object\n    async_json_file = AsyncJsonFile('data.json')\n\n    # Write data to the file\n    data = {\n        \"name\": \"Bob\",\n        \"age\": 25,\n        \"created_at\": datetime.now(),\n        \"id\": uuid.uuid4()\n    }\n\n    # The 'write' function automatically returns the loaded data. So you can either choose to do this:\n    loaded_data = await async_json_file.write(data, indent=4)\n    print(loaded_data)\n\n    # Or:\n    await async_json_file.write(data, indent=4)\n    loaded_data = await async_json_file.load()\n    print(loaded_data)\n\n# Run the async main function\nasyncio.run(main())\n```\n\n## License\n\nJSONKit is licensed under the MIT License. See the [LICENSE](./LICENSE) file for more details.\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A library for enhanced JSON file handling with support for datetime and UUID objects, both synchronously and asynchronously.",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/ayrun3412/JSONKit",
        "Repository": "https://github.com/ayrun3412/JSONKit"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fc83f7a75030c557f51dae0528dd7d2da791a601bf9a36c8ade259b5842713b6",
                "md5": "894758726bf0b9e1212b55b7f6a1e625",
                "sha256": "9dd2f02b7b38ba9dc084bbc445dba3caa02a4067b23228432b99574a628931f3"
            },
            "downloads": -1,
            "filename": "ayrun_jsonkit-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "894758726bf0b9e1212b55b7f6a1e625",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.12",
            "size": 5809,
            "upload_time": "2024-09-17T07:21:03",
            "upload_time_iso_8601": "2024-09-17T07:21:03.362314Z",
            "url": "https://files.pythonhosted.org/packages/fc/83/f7a75030c557f51dae0528dd7d2da791a601bf9a36c8ade259b5842713b6/ayrun_jsonkit-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3df9c02ed6d6df040d4758b3acfaadb5dbc8ba541c5967af389d7be7c61217c6",
                "md5": "1427378d9461124e8f07ff3ab65c241b",
                "sha256": "f9d280cd9b892c6be082e47e414f08a83e7982b00b8335f2e87ad9b51946595a"
            },
            "downloads": -1,
            "filename": "ayrun_jsonkit-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1427378d9461124e8f07ff3ab65c241b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.12",
            "size": 4479,
            "upload_time": "2024-09-17T07:21:05",
            "upload_time_iso_8601": "2024-09-17T07:21:05.276987Z",
            "url": "https://files.pythonhosted.org/packages/3d/f9/c02ed6d6df040d4758b3acfaadb5dbc8ba541c5967af389d7be7c61217c6/ayrun_jsonkit-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-17 07:21:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ayrun3412",
    "github_project": "JSONKit",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ayrun-jsonkit"
}
        
Elapsed time: 1.32371s