Name | py-jsonkit JSON |
Version |
0.1.0
JSON |
| download |
home_page | https://github.com/ayrun3412/JSONKit |
Summary | A library for enhanced JSON file handling with support for datetime and UUID objects, both synchronously and asynchronously. |
upload_time | 2024-09-17 11:39:45 |
maintainer | None |
docs_url | None |
author | ayrun |
requires_python | <4.0,>=3.12 |
license | MIT |
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 in Python</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.
- **Pretty Printing**: Pretty printing powered by the [rich](https://github.com/Textualize/rich) library!
## Installation
You can install JSONKit via pip:
```bash
pip install py-jsonkit
```
## Usage
#### π Loading JSON from a File
You can load a JSON file into a Python object easily:
```python
from jsonkit import JSONFile
# Initialize the JSONFile object
json_file = JSONFile('example.json')
# Load data from the file
data = json_file.load()
```
#### π Writing data to a JSON file:
You can also write some data to a JSONFile easily
```python
from jsonkit import JSONFile
from datetime import datetime
import uuid
# Initialize the JSONFile object
json_file = JSONFile('example.json')
# Example data
data_to_write = {
"name": "Alice",
"age": 30,
"created_at": datetime.now(),
"uid": uuid.uuid4()
}
# Insert to the JSON file
# JSONKit comes with custom encoding/decoding so you don't need to worry about parsing datetime or uuid objects!
# The `write` function returns the new data that is present in the JSON file after writing to it automatically, so you can store it in a variable like this:
new_returned_data = json_file.write(data_to_write, indent=4)
# Or, you can simply do this in the good old way:
json_file.write(data_to_write, indent=4)
new_data = json_file.load()
# NOTE: The method shown above will completely replace the old data with the new data. In case you want to append some data to a JSON file which of course, already contains some data, you can simply load that data first:
data = json_file.load()
# Then add some data to it:
data["......"] = "......"
data["woah this is some new data"] = "I am the value of the new data!"
# Then write this data back to the JSON File
json_file.write(data, indent=4)
```
#### π Pretty Printing
JSONKit also comes with pretty printing which is handled by the [rich](https://github.com/Textualize/rich) library!
```python
from jsonkit import JSONFile
# Intialize the JSONFile object
json_file = JSONFile('example.json')
# Pretty print all of the data in 'example.json' file to the console
# This will print the data with syntax hughlighting!
json_file.print_data()
```
#### π Asynchronous Support
JSONKit can also be used asynchronously using the `AsyncJSONFile` class!
```python
from jsonkit import AsyncJSONFile
import asyncio
# Create an instance of AsyncJSONFile
async_json_file = AsyncJSONFile('example.json')
# All of the methods that are available in 'JSONFile' class are also available here!
async def main():
# Loading data
data = await async_json_file.load()
# Writing data
data_to_insert = {
"...": "..."
}
await async_json_file.write(data_to_insert, indent=4)
# Pretty printing data
await async_json_file.print_data()
# Running the 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": "py-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/2e/22/4e6e24c25c9ac9856054ea2880e50b391ba574c0816aca96793e399f5a03/py_jsonkit-0.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 in Python</i> \ud83d\udc0d</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\n- **Asynchronous Operations**: Handle JSON files asynchronously using `aiofiles`.\n\n- **Custom Serialization**: Special handling for `datetime` and `UUID` types.\n\n- **Pretty Printing**: Pretty printing powered by the [rich](https://github.com/Textualize/rich) library!\n\n## Installation\n\nYou can install JSONKit via pip:\n\n```bash\npip install py-jsonkit\n```\n\n## Usage\n\n#### \ud83d\udc49 Loading JSON from a File\n\nYou can load a JSON file into a Python object easily:\n\n```python\nfrom jsonkit import JSONFile\n\n# Initialize the JSONFile object\njson_file = JSONFile('example.json')\n\n# Load data from the file\ndata = json_file.load()\n```\n\n#### \ud83d\udc49 Writing data to a JSON file:\n\nYou can also write some data to a JSONFile easily\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# Example data\ndata_to_write = {\n \"name\": \"Alice\",\n \"age\": 30,\n \"created_at\": datetime.now(),\n \"uid\": uuid.uuid4()\n}\n\n# Insert to the JSON file\n# JSONKit comes with custom encoding/decoding so you don't need to worry about parsing datetime or uuid objects!\n# The `write` function returns the new data that is present in the JSON file after writing to it automatically, so you can store it in a variable like this:\nnew_returned_data = json_file.write(data_to_write, indent=4)\n\n# Or, you can simply do this in the good old way:\njson_file.write(data_to_write, indent=4)\nnew_data = json_file.load()\n\n# NOTE: The method shown above will completely replace the old data with the new data. In case you want to append some data to a JSON file which of course, already contains some data, you can simply load that data first:\ndata = json_file.load()\n\n# Then add some data to it:\ndata[\"......\"] = \"......\"\ndata[\"woah this is some new data\"] = \"I am the value of the new data!\"\n\n# Then write this data back to the JSON File\njson_file.write(data, indent=4)\n```\n\n#### \ud83d\udc49 Pretty Printing\n\nJSONKit also comes with pretty printing which is handled by the [rich](https://github.com/Textualize/rich) library!\n\n```python\nfrom jsonkit import JSONFile\n\n# Intialize the JSONFile object\njson_file = JSONFile('example.json')\n\n# Pretty print all of the data in 'example.json' file to the console\n# This will print the data with syntax hughlighting!\njson_file.print_data()\n```\n\n#### \ud83d\udc49 Asynchronous Support\n\nJSONKit can also be used asynchronously using the `AsyncJSONFile` class!\n\n```python\nfrom jsonkit import AsyncJSONFile\nimport asyncio\n\n# Create an instance of AsyncJSONFile\nasync_json_file = AsyncJSONFile('example.json')\n\n# All of the methods that are available in 'JSONFile' class are also available here!\nasync def main():\n # Loading data\n data = await async_json_file.load()\n\n # Writing data\n data_to_insert = {\n \"...\": \"...\"\n }\n await async_json_file.write(data_to_insert, indent=4)\n\n # Pretty printing data\n await async_json_file.print_data()\n\n# Running the 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": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/ayrun3412/JSONKit",
"Repository": "https://github.com/ayrun3412/JSONKit"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5f8b7412b4555e761ae40334304aa73507fa80264b3edf2ed4c13441f8a96144",
"md5": "f0e48a7badcb139759486ef7030c6ffa",
"sha256": "d86f31a0b70d783f4b9a56bde94b683ea10f877c162be061dc0558ba9b761f6a"
},
"downloads": -1,
"filename": "py_jsonkit-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f0e48a7badcb139759486ef7030c6ffa",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.12",
"size": 6317,
"upload_time": "2024-09-17T11:39:43",
"upload_time_iso_8601": "2024-09-17T11:39:43.346903Z",
"url": "https://files.pythonhosted.org/packages/5f/8b/7412b4555e761ae40334304aa73507fa80264b3edf2ed4c13441f8a96144/py_jsonkit-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2e224e6e24c25c9ac9856054ea2880e50b391ba574c0816aca96793e399f5a03",
"md5": "8debd9213d985b20ae4b726883a2b204",
"sha256": "2184339f8be6066d28874bcbd5f8240f7123b41fa377b0ef80db59de3f9ef7a6"
},
"downloads": -1,
"filename": "py_jsonkit-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "8debd9213d985b20ae4b726883a2b204",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.12",
"size": 5083,
"upload_time": "2024-09-17T11:39:45",
"upload_time_iso_8601": "2024-09-17T11:39:45.022952Z",
"url": "https://files.pythonhosted.org/packages/2e/22/4e6e24c25c9ac9856054ea2880e50b391ba574c0816aca96793e399f5a03/py_jsonkit-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-17 11:39:45",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ayrun3412",
"github_project": "JSONKit",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "py-jsonkit"
}