معرفی شرکت ها


apjson-0.0.3


Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر

توضیحات

A simple asynchronus json prettifier.
ویژگی مقدار
سیستم عامل -
نام فایل apjson-0.0.3
نام apjson
نسخه کتابخانه 0.0.3
نگهدارنده []
ایمیل نگهدارنده []
نویسنده nect
ایمیل نویسنده -
آدرس صفحه اصلی -
آدرس اینترنتی https://pypi.org/project/apjson/
مجوز MIT License
# apjson `apjson` is an asynchonus prettifier for json-like objects and a simple implementation of the `json` module and decorators. ## Installation Install via pip: ``` pip install apjson ``` ## Example ```python from apjson import prettify, to_bytesio, jbytesio, jpretty import asyncio @jbytesio(sort_keys=True, check_circular=True) def sync_json(): return '{"in": "this", "example": "the", "json": "function", "is": "sync"}' @jpretty(silent=True) async def async_json(): return "{\"instead\": \"here\", \"is\": \"async\"}" async def main(): print((await to_bytesio('{"this": "is", "an": "example", "here": 123}')).read()) print(await prettify('{"this": "is", "another": "example", "here": True}')) print(await prettify(b"{\"X\": 123}")) print(await prettify(bytearray("{\"X\": 123}", encoding='utf-8'))) #every decorated function should be awaited (even sync) print((await sync_json()).read()) print(await async_json()) loop = asyncio.get_event_loop() loop.run_until_complete(main()) ``` ## Prettifier `prettify`: Prettifies and dumps the input (`str`, `bytes`, `bytearray`, `dict`) to json. Accepts every kwarg of `json.dumps`. ```python await prettify('{"this": "is", "an_": "example", "here": 123, "even": 1.02, "but": False}') await prettify(b"{\"X\": 123}") await prettify(bytearray("{\"X\": 123}", encoding='utf-8')) #or use the decorator @jpretty(silent=True) async def async_json(): #return a json-like str, bytes, bytearray, dict and the decorator will convert it return "{\"instead\": \"here\", \"is\": \"async\"}" ``` ## Other Utilities `to_bytes`: converts input (`str`, `bytes`, `bytearray`, `dict`) to `io.BytesIO` ```python await to_bytesio('{"this": "is", "an_": "example", "here": 123, "even": 1.02, "but": False}') #or use the decorator @jbytesio() async def json_to_bytesio(): #return a json-like str, bytes, bytearray, dict and the decorator will convert it return '{"in": "this", "example": "the", "json": "function", "is": "sync"}' ``` ## Notes You can use the boolean kwarg `silent` for skipping encoding exceptions. For custom encoder use the kwarg `encoder` instead of `cls` in the function that uses the custom encoder. You can decorate both sync and async functions but always return async function that needs to be awaited.


نیازمندی

مقدار نام
- check-manifest


زبان مورد نیاز

مقدار نام
>=3.5, <4 Python


نحوه نصب


نصب پکیج whl apjson-0.0.3:

    pip install apjson-0.0.3.whl


نصب پکیج tar.gz apjson-0.0.3:

    pip install apjson-0.0.3.tar.gz