jqlang / jq

Command-line JSON processor
https://jqlang.github.io/jq/
Other
30.23k stars 1.57k forks source link

Unexpected output #3108

Open HaanJde opened 5 months ago

HaanJde commented 5 months ago

Bug description

During developing a larger solution, unexpected output was generated.

Reproduction

Minimal test case:

echo '{"a":{"b":"g"}}{"a":{"c":"h"}}{"a":{"d":"i"}}{"e":{"f":"j"}}' | jq 'inputs'
{
  "a": {
    "c": "h"
  }
}
{
  "a": {
    "d": "i"
  }
}
{
  "e": {
    "f": "j"
  }
}

Expected behavior

The expected output was

{
  "a": {
    "b": "g"
  }
}
{
  "a": {
    "c": "h"
  }
}
{
  "a": {
    "d": "i"
  }
}
{
  "e": {
    "f": "j"
  }
}

Environment

itchyny commented 5 months ago

Invoke with -n option not to read the first value as query input; jq -n 'inputs'.