Numeric JSON results in step function are delivered as strings

0

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?

boukasa
已提問 2 年前檢視次數 916 次
2 個答案
0

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.

已回答 2 年前
0

Use the States.StringToJson function to convert string to number

"NumberValue.$": "States.StringToJson("$.numberAsString")"
AWS
已回答 5 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南