By using AWS re:Post, you agree to the Terms of Use

Numeric JSON results in step function are delivered as strings


When using GetQueueAttributes (SQS) to retrieve the number of messages available in a queue, the resulting JSON delivers numbers as strings, e.g. "ApproximateNumberOfMessages": "18"

That means a Choice step can't do a numeric comparison. I know in this particular case I'm always going to get a number, so I can use StringGreaterThan etc., but it's semantically wrong.

How can I convert the string value to a number so I can use numeric comparison operators?

1 Answers

You need to go step further and learn how comparison is done. It's done by functions Numeric Equals or StringEquals, so your input will be interpreted by the function you choose.

answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions