AsyncJ
AsyncJ - Python module for fast asynchronous work with JSON files
Examples
Get a dictionary from a JSON file
# Importing modules
import asyncio # To run the asynchronous main() function
from asyncj import AsyncJson # Main class used in the example
# Initialize the class with filename
asyncjson: AsyncJson = AsyncJson("test.json")
# The asynchronous main() function
async def main() -> None:
# Getting a dictionary
data: dict = await asyncjson.read()
# Displaying the resulting dictionary
print(data)
# Running the asynchronous main() function
if __name__ == "__main__":
asyncio.run(main())
Change dictionary in JSON file
# Importing modules
import asyncio # To run the asynchronous main() function
from asyncj import AsyncJson # Main class used in the example
from random import randint # To generate a random number
# Initialize the class with filename
asyncjson: AsyncJson = AsyncJson("test.json")
# The asynchronous main() function
async def main() -> None:
# Getting a dictionary
data: dict = await asyncjson.read()
# Getting a random number
random_number: int = randint(100, 999)
# Setting a new random value in the dictionary for the "test" key
data["test"] = random_number
# Writing the modified dictionary to a JSON file
await asyncjson.write(data)
# Running the asynchronous main() function
if __name__ == "__main__":
asyncio.run(main())
Requirements
Python version 3.8 or higher
Metadata
Release files for asyncj 1.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| asyncj-1.1.4.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asyncj-1.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.5 kB
Release files / asyncj-1.1.4.tar.gz
| Download URL | asyncj-1.1.4.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dc9f893b77de5a19b044986f24d8574cc71f1907ff6e5ed8ad61468f672250a2
|
|
BLAKE2b-256 checksum How to use checksums |
77b350d5400e94641a61812393e4e9a9bfab4ee4e12bb36d49159b9953c8e685
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Release files / asyncj-1.1.4-py3-none-any.whl
| Download URL | asyncj-1.1.4-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4d38d5812f51811a6ca15d94df74cfd36a9ffb94a2e53a39cec3640c995ea944
|
|
BLAKE2b-256 checksum How to use checksums |
ae54781ef5a7a6259e6b95228fe06e2c78be5f334514b297cd06331efdb18d61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|