Const
SQS Envelope to extract array of Records
The record's body parameter is a string and needs to be parsed against the provided schema.
body
If you know that the body is a JSON string, you can use JSONStringified to parse it, for example:
JSONStringified
import { JSONStringified } from '@aws-lambda-powertools/helpers';import { SqsEnvelope } from '@aws-lambda-powertools/parser/envelopes/sqs';const schema = z.object({ name: z.string(),});const parsed = SqsEnvelope.parse(event, JSONStringified(schema)); Copy
import { JSONStringified } from '@aws-lambda-powertools/helpers';import { SqsEnvelope } from '@aws-lambda-powertools/parser/envelopes/sqs';const schema = z.object({ name: z.string(),});const parsed = SqsEnvelope.parse(event, JSONStringified(schema));
SQS Envelope to extract array of Records
The record's
bodyparameter is a string and needs to be parsed against the provided schema.If you know that the
bodyis a JSON string, you can useJSONStringifiedto parse it, for example: