Skip to main content

Pass JSON as Input

Assuming the client passed input as JSON, you can easily convert the input data to a python dictionary:

# json/
import json

def cape_handler(data):
x = json.loads(data)
return x
except json.decoder.JSONDecodeError:
return 'please pass valid json'

You can pass this json via the CLI.

Valid JSON:

$ cape test json '{"hello": "world"}'
{'hello': 'world'}

Invalid JSON:

$ cape test json hello world
please pass valid json


We are actively soliciting feedback from our beta. Please use this form to provide feedback.