gron icon indicating copy to clipboard operation
gron copied to clipboard

ungron doesn't reproduce streamed JSON

Open joeshaw opened this issue 5 years ago • 2 comments

Consider a multi-line "stream" JSON file:

{"one": 1}
{"two": 2}
{"three": 3}

Running gron -s on this file produces:

json = [];
json[0] = {};
json[0].one = 1;
json[1] = {};
json[1].two = 2;
json[2] = {};
json[2].three = 3;

Running gron -u and gron -u -s on that output produces:

[
  {
    "one": 1
  },
  {
    "two": 2
  },
  {
    "three": 3
  }
]

Note that this was transformed into a JSON list. That makes sense with gron -u but it would be nice if gron -u -s understood this and produced a file that was semantically equivalent to the first one.

joeshaw avatar Apr 27 '20 14:04 joeshaw

In addition, this would enable gron -u -s to output lines in a streaming fashion (as the flag implies). This would be great, since at the moment it's very easy to make gron -s large.jsonl | gron -u eat up all memory and die.

asayers avatar Jun 24 '20 08:06 asayers

Try fastgron. It's much faster and also handles streaming in this way.

michaelmior avatar Nov 13 '23 13:11 michaelmior