Skip to main content
Solved

Branching a pipeline based on the number of records in a fetched JSON

  • July 9, 2024
  • 0 replies
  • 291 views

Forum|alt.badge.img+4

Currently my pipeline:

  1. Does a JSON Fetch to retrieve a JSON response
  2. Does an Iterate over JSON records

After the iterate I'd like to add a condition step that checks whether the # of JSON records is exactly 2   and then branch accordingly

My iterate JSON step is Step 'd'.   I'm trying to figure out the right syntax to use in my condition step.

In the advanced expression of my condition step I've tried  {{ d | count}}=2   {{ d | count}}==2   {{ d | length}}=2   {{ d | length}}==2   and all always resolve to 'True' even when the returned json only has 1 record

Any help is appreciated.

Best answer by JohnErdmann

Try this:

{{ d | count == 2 }}

The expected return value of the above would be TRUE. The expected return value of {{ d | count}}==2 would be string literal 2==2 because it is not encapsulated in the curly braces.

This topic has been closed for replies.

Forum|alt.badge.img+1
  • Registered
  • Answer
  • July 10, 2024

Try this:

{{ d | count == 2 }}

The expected return value of the above would be TRUE. The expected return value of {{ d | count}}==2 would be string literal 2==2 because it is not encapsulated in the curly braces.