# 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
```shell
pip install sceptre-json-resolver
```
To install from this git repo
```shell
pip install git+https://github.com/Sceptre/sceptre-json-resolver.git
```
## Usage/Examples
```yaml
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:
```yaml
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:
```yaml
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](https://pypi.org/project/sceptre-file-resolver/),
serialize the object to a string then pass it to a parameter:
```yaml
parameters:
hounds: !to_json [ !file 'hounds.json' ]
```
Make a request to a REST API using the
[sceptre-request-resolver](https://pypi.org/project/sceptre-request-resolver/),
deserialize the response to a json object then pass it to a parameter:
```yaml
sceptre_user_data:
hounds: !from_json
- !request 'https://dog.ceo/api/breed/hound/list'
```
Raw data
{
"_id": null,
"home_page": "https://github.com/Sceptre/sceptre-json-resolver",
"name": "sceptre-json-resolver",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<3.12",
"maintainer_email": "",
"keywords": "sceptre,sceptre-resolver",
"author": "Sceptre",
"author_email": "sceptreorg@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/fb/35/adf12a90ca1ac6da25a01620b1c05bac6439cc79469ac8686e4de7d5be61/sceptre_json_resolver-0.1.0.tar.gz",
"platform": null,
"description": "# sceptre-json-resolver\n\nA Sceptre resolver to serialize and deserialize json.\n\n## Motivation\n\nThere are use cases where you may want to pass in either a string\nor a json object to a cloudformation or sceptre_user_data parameter.\nThis simple resolver can take some json and serialize it or deserialize\nit before passing it into a cloudformation parameter or a\nscepter_user_data parameter.\n\n## Installation\n\nTo install directly from PyPI\n```shell\npip install sceptre-json-resolver\n```\n\nTo install from this git repo\n```shell\npip install git+https://github.com/Sceptre/sceptre-json-resolver.git\n```\n\n## Usage/Examples\n\n```yaml\nparameters|sceptre_user_data:\n <name>: !from_json [ <string> ]\n\nparameters|sceptre_user_data:\n <name>: !to_json [ <json object> ]\n```\n\n__NOTE__: This resolver expects a single-item list argument.\n\n## Basic Examples\n\nTake some json object serialize it to a string then pass it to a parameter:\n```yaml\nparameters:\n myparam: !to_json [{\"key\": \"value\"}]\n```\n__Note__: The string `'{\"key\": \"value\"}'` is passed to myparam\n\n\nTake a string deserialize it to a json object then pass it to a parameter:\n```yaml\nsceptre_user_data:\n myparam: !from_json ['{\"key\": \"value\"}']\n```\n__Note__: The object `{\"key\": \"value\"}` is passed to myparam\n\n\n## Nested resolver examples\n\nThese use case requires the nested resolver feature in\nSceptre version 4.1 and greater.\n\n\nLoad a json object from a file using the\n[sceptre file resolver](https://pypi.org/project/sceptre-file-resolver/),\nserialize the object to a string then pass it to a parameter:\n```yaml\nparameters:\n hounds: !to_json [ !file 'hounds.json' ]\n```\n\n\nMake a request to a REST API using the\n[sceptre-request-resolver](https://pypi.org/project/sceptre-request-resolver/),\ndeserialize the response to a json object then pass it to a parameter:\n```yaml\nsceptre_user_data:\n hounds: !from_json\n - !request 'https://dog.ceo/api/breed/hound/list'\n```\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "A Sceptre resolver to serialize and deserialize json",
"version": "0.1.0",
"split_keywords": [
"sceptre",
"sceptre-resolver"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0c5a1496fc884acf3aaccecddd7bc0dacb27583a285d01426158f4dc68950683",
"md5": "a619875a38d4c43fa724c19c0bcb18c1",
"sha256": "faa6bde734aedcd96f5abe68e2aabe8948da725a67447300c13592a247aab85e"
},
"downloads": -1,
"filename": "sceptre_json_resolver-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a619875a38d4c43fa724c19c0bcb18c1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<3.12",
"size": 3331,
"upload_time": "2023-04-18T18:03:58",
"upload_time_iso_8601": "2023-04-18T18:03:58.865155Z",
"url": "https://files.pythonhosted.org/packages/0c/5a/1496fc884acf3aaccecddd7bc0dacb27583a285d01426158f4dc68950683/sceptre_json_resolver-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fb35adf12a90ca1ac6da25a01620b1c05bac6439cc79469ac8686e4de7d5be61",
"md5": "c28007b0c28be0d272b6f84f703ca1f1",
"sha256": "b5a49109f398732b523aefcbf0ffecdb7e9b26e7491213f5cd767a61274e570c"
},
"downloads": -1,
"filename": "sceptre_json_resolver-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "c28007b0c28be0d272b6f84f703ca1f1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<3.12",
"size": 2697,
"upload_time": "2023-04-18T18:04:00",
"upload_time_iso_8601": "2023-04-18T18:04:00.779927Z",
"url": "https://files.pythonhosted.org/packages/fb/35/adf12a90ca1ac6da25a01620b1c05bac6439cc79469ac8686e4de7d5be61/sceptre_json_resolver-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-18 18:04:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "Sceptre",
"github_project": "sceptre-json-resolver",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"circle": true,
"tox": true,
"lcname": "sceptre-json-resolver"
}