title: reading and printing multi objects json file in linux
body: <p>I have a multi objects (millions) json file which I want to extract the values of some keys and print them. This should be very fast.</p>
  <p>the file looks like:</p>
  <pre><code>{&quot;a&quot;: &quot;text&quot;, &quot;b&quot;: 2, &quot;c&quot;: &quot;text&quot;, &quot;d&quot;: &quot;text&quot;, &quot;e&quot;: &quot;text&quot;, &quot;f&quot;: &quot;text&quot;, &quot;g&quot;: &quot;N&quot;, &quot;h&quot;: &quot;text&quot;, &quot;i&quot;: 11, &quot;j&quot;: &quot;text&quot;, &quot;k&quot;: &quot;&quot;}
  {&quot;a&quot;: &quot;text&quot;, &quot;b&quot;: 2, &quot;c&quot;: &quot;text&quot;, &quot;d&quot;: &quot;text&quot;, &quot;e&quot;: &quot;text&quot;, &quot;f&quot;: &quot;text&quot;, &quot;g&quot;: &quot;N&quot;, &quot;h&quot;: &quot;text&quot;, &quot;i&quot;: 11, &quot;j&quot;: &quot;text&quot;, &quot;k&quot;: &quot;&quot;}
  </code></pre>
  <p>the code I wrote looks like:</p>
  <pre><code>import sys, json; 
  data=json.load(sys.stdin) ; 
  print('{}\t{}\t{}'.format(data.get('a',''),data.get('b',''),data.get('c','')))
  </code></pre>
  <p>when I run this with <code>head -1 file.txt | extract.py</code> it works, but with <code>cat file.txt | extract.py</code> I get this error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
    File &quot;/usr/lib64/python3.7/json/__init__.py&quot;, line 296, in load
      parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
    File &quot;/usr/lib64/python3.7/json/__init__.py&quot;, line 348, in loads
      return _default_decoder.decode(s)
    File &quot;/usr/lib64/python3.7/json/decoder.py&quot;, line 340, in decode
      raise JSONDecodeError(&quot;Extra data&quot;, s, end)
  json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 581)
  </code></pre>
  <p>I choose python as it looks like the one with the best performance, but if you know other language which you think is faster - please post your answer as well.</p>
  <p>the idea in the end is to do something like:</p>
  <pre><code>cat file.txt | extract.py | &lt;farther_processing...&gt;
  </code></pre>
  <p><strong>Update:</strong>
  after the help from @syntonym and @oguzismail <code>python</code> and <code>jq</code> working for me, those are the results for small 150k file:</p>
  <pre><code>jq -r '[.a, .b] | @tsv' file.txt:
  real    0m7.939s
  user    0m6.059s
  sys     0m0.945s
  
  python (as the suggested solution):
  real    0m2.374s
  user    0m2.327s
  sys     0m0.012s
  </code></pre>
  <p>The end solution will be used on an hourly schedule for dozens of files (1m-5g) each hour.</p>