title: Convert .txt file to json using shell script or jq command
body: <p>I have the <strong>data.txt</strong> file containing below information:</p>
  <pre><code>611111|22|53|200003|ADD|234566|REMOVE|546768|647|Return|5647|746927|ADD|345677858|REMOVE|546768|64774|Return|5647|2134
  611112|24|53|200043|ADD|234576|REMOVE|5467658|647|Return|5687|746927|ADD|445677858|REMOVE|546768|64774|Return|5647|2334
  </code></pre>
  <p>How can I convert into <strong>.json</strong> file like below :</p>
  <p><strong>Output required :</strong></p>
  <pre><code>[
    {
      &quot;ProductId&quot;: &quot;611111&quot;,
      &quot;PIDT&quot;: &quot;22&quot;,
      &quot;RPID&quot;: &quot;53&quot;,
      &quot;OfferId&quot;: &quot;20003&quot;,
      &quot;Product1&quot;: 
      [
        {
          &quot;Action&quot;: &quot;ADD&quot;,
          &quot;ProductOfferId&quot;: &quot;234566&quot;,
        },
        {
          &quot;Action&quot;: &quot;REMOVE&quot;,
         &quot;ProductOfferId&quot;: &quot;546768&quot;,
          &quot;RemoveProduct1Instance&quot;: &quot;647&quot;,
        },
        {
          &quot;Action&quot;: &quot;RETURN&quot;,
         &quot;RemoveProduct1Instance&quot;: &quot;5647&quot;,
          &quot;ProductOfferId&quot;: &quot;746927&quot;,
        }   
      ]
      &quot;Product2&quot;: 
      [
        {
          &quot;Action&quot;: &quot;ADD&quot;,
          &quot;NewComponentOfferId&quot;: &quot;345677858&quot;,
        },
        {
          &quot;Action&quot;: &quot;REMOVE&quot;,
         &quot;ComponentOfferId&quot;: &quot;546768&quot;,
          &quot;RemoveProduct2Instance&quot;: &quot;64774&quot;,
        },
        {
          &quot;Action&quot;: &quot;RETURN&quot;,
         &quot;RemoveProduct2Instance&quot;: &quot;5647&quot;,
         &quot;ProductOfferId&quot;: &quot;2134&quot;
        }   
      ]
    }
  ]    
  </code></pre>
  <p>And like wise for every line.
  Please suggest how we can obtain this using <strong>jq command</strong> or <strong>shell scripting</strong>?</p>