1

If I have three json objects in : test.json

{
  "queue": "A",
  "field1": 22,
  "field2": 2,
                 "unique_field": 0
}
{
  "queue": "B",
  "field1": 39,
  "field2": 3
}
{
  "queue": "C",
  "field1": 336,
  "field2": 5
}

Running MLR to convert to CSV returns two unique sets based on headers

./mlr --j2c cat test.json
queue,field1,field2,unique_field
A,22,2,0

queue,field1,field2
B,39,3
C,336,5

What I would like is for MLR to pad any missing fields with null so only 1 header is present

queue,field1,field2,unique_field
A,22,2,0
B,39,3,null
C,336,5,null

I am not sure what to try yet, as need expertise from MLR community

Fravadona
  • 13,917
  • 1
  • 23
  • 35
pankajsaha
  • 13
  • 5

1 Answers1

2

You must use the unsparsify verb:

./mlr --j2c unsparsify test.json
aborruso
  • 4,938
  • 3
  • 23
  • 40