Set of useful methods to speed up conversion of objects to AWS services
Project description
DynoDino
DynoDino is a set of useful methods to speed up the conversion of objects to AWS services, specifically DynamoDB. This library allows you to easily convert JSON data to DynamoDB format and vice versa.
Installation
To install the library, use pip:
pip install dyno-dino
Features
JSON to DynamoDB Conversion
The library provides methods to convert JSON data structures to the format accepted by DynamoDB. This includes converting common data types like strings, numbers, lists, and nested dictionaries.
Example Usage:
from dyno_dino import convert_json_to_dynamodb
json_data = {
"name": "Victor",
"phone": "5587975648710",
"age": 30,
"is_verified": True,
"account_balance": 1234.56,
"nested_object": {
"key1": "value1",
"key2": 2
},
"list_data": ["item1", "item2", "item3"]
}
dynamodb_data = convert_json_to_dynamodb(json_data)
print(dynamodb_data)
DynamoDB to JSON Conversion
You can also convert data from DynamoDB format back to JSON, making it easier to manipulate and visualize the data.
Example Usage:
from dyno_dino import convert_dynamodb_to_json
dynamodb_data = {
"M": {
"name": {"S": "Victor"},
"phone": {"S": "5587975648710"},
"age": {"N": "30"},
"is_verified": {"BOOL": True},
"account_balance": {"N": "1234.56"},
"nested_object": {
"M": {
"key1": {"S": "value1"},
"key2": {"N": "2"}
}
},
"list_data": {"L": [
{"S": "item1"},
{"S": "item2"},
{"S": "item3"}
]}
}
}
json_data = convert_dynamodb_to_json(dynamodb_data)
print(json_data)
Available Methods
convert_json_to_dynamodb(data: dict) -> dict
Converts a JSON dictionary to DynamoDB format.
- Parameters:
data
(dict): JSON dictionary to be converted.- Returns:
- Dictionary in DynamoDB format.
convert_dynamodb_to_json(dynamodb_data: dict) -> dict
Converts a DynamoDB format dictionary to JSON.
- Parameters:
dynamodb_data
(dict): DynamoDB format dictionary to be converted.remove_content
(bool, optional): Whether to remove the "content" key if it exists. Default isFalse
- Returns:
- JSON dictionary.
Contributing
Contributions are welcome! Feel free to open issues or pull requests on the GitHub repository.
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 dyno_dino-1.0.8.tar.gz
.
File metadata
- Download URL: dyno_dino-1.0.8.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a4b7dc90a8e0688fd26d14d8a24826f7bf000d9d59dfe99552c750950c31c54 |
|
MD5 | 55f5680a5c90202e2a21b9e8faeb9a5d |
|
BLAKE2b-256 | bb2284994b6285a56d6fe2fdf9bf8f756e5162d06204a7c843aa5024d10c8e7e |
File details
Details for the file dyno_dino-1.0.8-py3-none-any.whl
.
File metadata
- Download URL: dyno_dino-1.0.8-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa685ef0fe549e61a7d333dbae7cb4b94d833baa50ba161ed8d57ee783298348 |
|
MD5 | 6c8494b8e8485450a0ce82cb084f675f |
|
BLAKE2b-256 | 529f54f058b9b14e609b9be1e0f136efa549e1835538f98ed4848ca6b4dd9c02 |