A Sceptre resolver to serialize and deserialize json
Project description
sceptre-json-resolver
A Sceptre resolver to serialize and deserialize json.
Motivation
There are use cases where you may want to pass in either a string or a json object to a cloudformation or sceptre_user_data parameter. This simple resolver can take some json and serialize it or deserialize it before passing it into a cloudformation parameter or a scepter_user_data parameter.
Installation
To install directly from PyPI
pip install sceptre-json-resolver
To install from this git repo
pip install git+https://github.com/Sceptre/sceptre-json-resolver.git
Usage/Examples
parameters|sceptre_user_data:
<name>: !from_json [ <string> ]
parameters|sceptre_user_data:
<name>: !to_json [ <json object> ]
NOTE: This resolver expects a single-item list argument.
Basic Examples
Take some json object serialize it to a string then pass it to a parameter:
parameters:
myparam: !to_json [{"key": "value"}]
Note: The string '{"key": "value"}'
is passed to myparam
Take a string deserialize it to a json object then pass it to a parameter:
sceptre_user_data:
myparam: !from_json ['{"key": "value"}']
Note: The object {"key": "value"}
is passed to myparam
Nested resolver examples
These use case requires the nested resolver feature in Sceptre version 4.1 and greater.
Load a json object from a file using the sceptre file resolver, serialize the object to a string then pass it to a parameter:
parameters:
hounds: !to_json [ !file 'hounds.json' ]
Make a request to a REST API using the sceptre-request-resolver, deserialize the response to a json object then pass it to a parameter:
sceptre_user_data:
hounds: !from_json
- !request 'https://dog.ceo/api/breed/hound/list'
Project details
Release history Release notifications | RSS feed
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
Hashes for sceptre_json_resolver-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5a49109f398732b523aefcbf0ffecdb7e9b26e7491213f5cd767a61274e570c |
|
MD5 | c28007b0c28be0d272b6f84f703ca1f1 |
|
BLAKE2b-256 | fb35adf12a90ca1ac6da25a01620b1c05bac6439cc79469ac8686e4de7d5be61 |
Hashes for sceptre_json_resolver-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | faa6bde734aedcd96f5abe68e2aabe8948da725a67447300c13592a247aab85e |
|
MD5 | a619875a38d4c43fa724c19c0bcb18c1 |
|
BLAKE2b-256 | 0c5a1496fc884acf3aaccecddd7bc0dacb27583a285d01426158f4dc68950683 |