Utils to work with json
Project description
kr
Utils to work with json
To install: pip install kr
Overview
The kr
package provides utility functions to handle JSON data, specifically focusing on error handling and reporting. It includes functions to convert error objects into dictionary or JSON format, optionally including traceback information to aid in debugging.
Features
- Error Object Serialization: Convert exceptions and errors into a more readable and structured JSON format.
- Traceback Inclusion: Option to include traceback details in the serialized error output, which can be very helpful for debugging.
Functions
get_dict_of_error_object(error_object, with_traceback=True)
Converts an error object into a dictionary with keys for the error type and message. Optionally includes a traceback if with_traceback
is set to True
.
Parameters:
- error_object: The exception object to serialize.
- with_traceback (optional): Boolean flag to determine if traceback information should be included. Defaults to
True
.
Returns:
- A dictionary containing the error type, message, and optionally the traceback.
Example:
try:
1 / 0
except Exception as e:
error_info = get_dict_of_error_object(e)
print(error_info)
get_json_of_error_object(error_object)
Converts an error object into a JSON string by utilizing get_dict_of_error_object
.
Parameters:
- error_object: The exception object to serialize.
Returns:
- A JSON string representation of the error object.
Example:
try:
1 / 0
except Exception as e:
error_json = get_json_of_error_object(e)
print(error_json)
Installation
Install the package using pip:
pip install kr
This package can be a useful tool in applications where error handling and reporting are crucial, especially in environments where JSON is the preferred format for data interchange.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file kr-0.0.5.tar.gz
.
File metadata
- Download URL: kr-0.0.5.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
7f277814c3996f47881fe27618792de1c82f39a9e41044d2e9e55e2d5835454c
|
|
MD5 |
331fd793f970c5a6b345cb94edd82c53
|
|
BLAKE2b-256 |
bac2aae4df6c9744bf53c6187ed8b60b58c98ba8506559db220281e24d1edb72
|
File details
Details for the file kr-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: kr-0.0.5-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
2310b1592be6e413dd58eeb67de14d1983b80b8e5991e179c1625429ca97dacb
|
|
MD5 |
d4ef1d6ac9a2ae48f0e6f4751ea639b9
|
|
BLAKE2b-256 |
32df76f05187dbf0af1df66914361b8381183fdb5e72e54994e54cd4fb8903e2
|