title: How to use an if conditional in a WireMock JSON stub?
body: <p>I need to use if conditional in my stub. I know there are the different scenarios you can create with body patterns but this does not work in my case because I am getting a variable number of objects in the payload and I need to use a for loop to check every one of them.
  So my request payload would look similar to this:</p>
  <pre><code>[
     { &quot;todo_id&quot;: 1 },
     { &quot;todo_id&quot;: null },
     { &quot;todo_id&quot;: 3 }
  ]
  </code></pre>
  <p>I want to respond with the <code>todo_id</code> where there was one and respond with a random integer where there is <code>null</code>, so my response payload so far is this:</p>
  <pre><code>&quot;response&quot;: {
      &quot;status&quot;: 200,
      &quot;body&quot;: &quot;[ {{#each (jsonPath request.body '$') as |todo|}}
                    { \&quot;todo_id\&quot;:
                        {{#if (todo.todo_id == null) }}
                            1{{randomValue length=1 type='NUMERIC'}}
                        {{else}}
                            {{todo.todo_id}}
                        {{/if}}
                  },
              {{/each}} ]&quot;
  }
  </code></pre>
  <p>I know you can't body spaced out like that but I did it to make it easer to read the code.</p>
  <p>So the for each loop definitely works, I've tried it without if statement and it works fine. But I cannot get the if statement working for me.</p>
  <p>Any ideas on how to implement something like this?</p>