jq read .txt file and write the values to json file
<p>I want to use <code>jq</code> to parse a <code>.txt</code> file with a list of country codes and write them to the value in a JSON object.</p>

<p>Here is what I have so far:</p>

<pre><code>cat myfile.json | 
jq -R -f test_id.txt 'select(.country == []).country = "test_id.txt"' &gt; newfile.json
</code></pre>

<p>Where <code>.txt</code> file looks like this:</p>

<pre><code>"NSC"
"KZC"
"KCC"
"KZL"
"NZG"
"VRU"
"ESM"
"KZF"
"SFU"
"EWF"
"KQY"
"KQV"
</code></pre>

<p>and my JSON looks like this:</p>

<pre><code>{
  "scsRequestId": null,
  "includeMetadata": true,
  "includeHoldings": true,
  "country": [],
  "region": [],
  "oclcSymbol": []
}
</code></pre>

<p>Here is the error I am getting:</p>

<pre><code>jq: error: syntax error, unexpected QQSTRING_START, expecting $end (Unix shell quoting issues?) at &lt;top-level&gt;, line 2:
"KZC"
jq: 1 compile error
</code></pre>

<p>I want the list of country codes to go into the country array.</p>