title: How to pass Json variable as inputs in Azure DevOps pipeline task
body: <p>I am forming a JSON dynamically during the pipeline run based on few pipeline parameters and pre-defined environment variables and trying to pass this JSON as an input in subsequent pipeline task.</p>
  <pre><code>   jobs:
       - job: PayloadCreation
         pool: linux-agent (or windows)
         steps:
          - ${{ each app in apps }}:
              - bash: |
                  payload=$(jq .artifact += [{&quot;name&quot;: &quot;${{ app.name}}, &quot;version&quot;:&quot;$(Build.BuildId)&quot;}]' artifact.json)
                  echo $payload &gt; artifact.json
                  echo &quot;##vso[task.setvariable variable=payload]$payload&quot;
  
  </code></pre>
  <p>I am getting the output of <code>artifact.json</code> as well as variable $payload as follows -</p>
  <pre><code>&quot;artifacts&quot;: [
    {
      &quot;name&quot;:&quot;service-a&quot;,
      &quot;version&quot;:&quot;1.0.0&quot;
    },
    {
      &quot;name&quot;:&quot;service-b&quot;,
      &quot;version&quot;: &quot;1.0.1&quot;
    }
   ]
  }
  </code></pre>
  <p>Subsequently, I am trying to use this JSON variable to pass it as input in the following job and unable to do so.</p>
  <pre><code> - job: JobB
     steps:
       - task: SericeNow-DevOps-Agent-Artifact-Registration@1
         inputs:
           connectedServiceName: 'test-SC'
           artifactsPayload: $(payload)
  </code></pre>
  <p>It is unable to read the JSON as input variable. I get the below error -
  <code>Artifact Registration could not be sent due to the exception: Unexpected token $ in JSON at position 0</code></p>
  <p>Is there any other way a JSON could be passed as input variable?</p>