exportconsthandler = async (event: SQSEvent): Promise<unknown> => { constrecords = extractDataFromEnvelope<Array<MessageBody>>(event, SQS); for (constrecordinrecords) { // records is now a list containing the deserialized body of each message const { customerId } = record; } };
Searches and extracts data using JMESPath
Envelope being the JMESPath expression to extract the data you're after
Built-in JMESPath functions include:
powertools_json
,powertools_base64
,powertools_base64_gzip
Example
We provide built-in envelopes for popular AWS Lambda event sources to easily decode and/or deserialize JSON objects.
Example