Skip to content

Instantly share code, notes, and snippets.

@richardgrantserverless
Created April 21, 2022 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardgrantserverless/cb17852e9bb1ea59fb007b9581fbf89a to your computer and use it in GitHub Desktop.
Save richardgrantserverless/cb17852e9bb1ea59fb007b9581fbf89a to your computer and use it in GitHub Desktop.
import json
import sys
sys.path.insert(0, 'src/vendor')
from jsonpath_rw import jsonpath, parse
def hello(event, context):
body = {
"message": "Python Function executed successfully!"
}
jsonpath.auto_id_field = 'id'
data = [match.value for match in parse('foo[*].id').find({'foo': [{'id': 'bizzle'}, {'baz': 3}]})]
response = {
"statusCode": 200,
"body": json.dumps(body),
"data": json.dumps(data)
}
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment