
mlr --ijson --oxtab flatten ./reg-test/input/flatten-input-2.json
hostname                    localhost
pid                         12345
req.id                      6789
req.method                  GET
req.path                    api/check
req.host                    foo.bar
req.headers.host            bar.baz
req.headers.user-agent      browser
res.status_code             200
res.header.content-type     text
res.header.content-encoding plain
empty1                      {}
empty2                      []
wrapper.empty3              {}
wrapper.emtpy4              []

mlr --ijson --oxtab flatten -s : ./reg-test/input/flatten-input-2.json
hostname                    localhost
pid                         12345
req:id                      6789
req:method                  GET
req:path                    api/check
req:host                    foo.bar
req:headers:host            bar.baz
req:headers:user-agent      browser
res:status_code             200
res:header:content-type     text
res:header:content-encoding plain
empty1                      {}
empty2                      []
wrapper:empty3              {}
wrapper:emtpy4              []

mlr --ijson --oxtab flatten -s . ./reg-test/input/flatten-input-2.json
hostname                    localhost
pid                         12345
req.id                      6789
req.method                  GET
req.path                    api/check
req.host                    foo.bar
req.headers.host            bar.baz
req.headers.user-agent      browser
res.status_code             200
res.header.content-type     text
res.header.content-encoding plain
empty1                      {}
empty2                      []
wrapper.empty3              {}
wrapper.emtpy4              []

mlr --json flatten -f req ./reg-test/input/flatten-input-2.json
{
  "hostname": "localhost",
  "pid": 12345,
  "req.id": 6789,
  "req.method": "GET",
  "req.path": "api/check",
  "req.host": "foo.bar",
  "req.headers.host": "bar.baz",
  "req.headers.user-agent": "browser",
  "res": {
    "status_code": 200,
    "header": {
      "content-type": "text",
      "content-encoding": "plain"
    }
  },
  "empty1": {},
  "empty2": [],
  "wrapper": {
    "empty3": {},
    "emtpy4": []
  }
}

mlr --json flatten -f res ./reg-test/input/flatten-input-2.json
{
  "hostname": "localhost",
  "pid": 12345,
  "req": {
    "id": 6789,
    "method": "GET",
    "path": "api/check",
    "host": "foo.bar",
    "headers": {
      "host": "bar.baz",
      "user-agent": "browser"
    }
  },
  "res.status_code": 200,
  "res.header.content-type": "text",
  "res.header.content-encoding": "plain",
  "empty1": {},
  "empty2": [],
  "wrapper": {
    "empty3": {},
    "emtpy4": []
  }
}

mlr --oflatsep @ --from ./reg-test/input/flatten-input-2.json --ijson --oxtab flatten
hostname                    localhost
pid                         12345
req@id                      6789
req@method                  GET
req@path                    api/check
req@host                    foo.bar
req@headers@host            bar.baz
req@headers@user-agent      browser
res@status_code             200
res@header@content-type     text
res@header@content-encoding plain
empty1                      {}
empty2                      []
wrapper@empty3              {}
wrapper@emtpy4              []

mlr --oflatsep @ --from ./reg-test/input/flatten-input-2.json --ijson --oxtab flatten -s %
hostname                    localhost
pid                         12345
req%id                      6789
req%method                  GET
req%path                    api/check
req%host                    foo.bar
req%headers%host            bar.baz
req%headers%user-agent      browser
res%status_code             200
res%header%content-type     text
res%header%content-encoding plain
empty1                      {}
empty2                      []
wrapper%empty3              {}
wrapper%emtpy4              []

mlr --ixtab --ojson unflatten ./reg-test/input/unflatten-input.xtab
{
  "hostname": "localhost",
  "pid": 12345,
  "req": {
    "id": 6789,
    "method": "GET",
    "path": "api/check",
    "host": "foo.bar",
    "headers": {
      "host": "bar.baz",
      "user-agent": "browser"
    }
  },
  "res": {
    "status_code": 200,
    "header": {
      "content-type": "text",
      "content-encoding": "plain"
    }
  },
  "empty1": {},
  "empty2": [],
  "wrapper": {
    "empty3": {},
    "emtpy4": []
  }
}

mlr --ixtab --ojson unflatten -s : ./reg-test/input/unflatten-input.xtab
{
  "hostname": "localhost",
  "pid": 12345,
  "req": {
    "id": 6789,
    "method": "GET",
    "path": "api/check",
    "host": "foo.bar",
    "headers": {
      "host": "bar.baz",
      "user-agent": "browser"
    }
  },
  "res": {
    "status_code": 200,
    "header": {
      "content-type": "text",
      "content-encoding": "plain"
    }
  },
  "empty1": {},
  "empty2": [],
  "wrapper": {
    "empty3": {},
    "emtpy4": []
  }
}

mlr --ixtab --ojson unflatten -s . ./reg-test/input/unflatten-input.xtab
{
  "hostname": "localhost",
  "pid": 12345,
  "req": {
    "id": 6789,
    "method": "GET",
    "path": "api/check",
    "host": "foo.bar",
    "headers": {
      "host": "bar.baz",
      "user-agent": "browser"
    }
  },
  "res": {
    "status_code": 200,
    "header": {
      "content-type": "text",
      "content-encoding": "plain"
    }
  },
  "empty1": {},
  "empty2": [],
  "wrapper": {
    "empty3": {},
    "emtpy4": []
  }
}

mlr --ixtab --ojson --oflatsep @ unflatten ./reg-test/input/unflatten-input-2.xtab
{
  "hostname": "localhost",
  "pid": 12345,
  "req": {
    "id": 6789,
    "method": "GET",
    "path": "api/check",
    "host": "foo.bar",
    "headers": {
      "host": "bar.baz",
      "user-agent": "browser"
    }
  },
  "res": {
    "status_code": 200,
    "header": {
      "content-type": "text",
      "content-encoding": "plain"
    }
  },
  "empty1": {},
  "empty2": [],
  "wrapper": {
    "empty3": {},
    "emtpy4": []
  }
}

mlr --xtab unflatten -s . then flatten -s @ ./reg-test/input/unflatten-input.xtab
hostname                    localhost
pid                         12345
req@id                      6789
req@method                  GET
req@path                    api/check
req@host                    foo.bar
req@headers@host            bar.baz
req@headers@user-agent      browser
res@status_code             200
res@header@content-type     text
res@header@content-encoding plain
empty1                      {}
empty2                      []
wrapper@empty3              {}
wrapper@emtpy4              []

mlr --ixtab --ojson unflatten -s . -f req ./reg-test/input/unflatten-input.xtab
{
  "hostname": "localhost",
  "pid": 12345,
  "req": {
    "id": 6789,
    "method": "GET",
    "path": "api/check",
    "host": "foo.bar",
    "headers": {
      "host": "bar.baz",
      "user-agent": "browser"
    }
  },
  "res": {
    "status_code": 200,
    "header": {
      "content-type": "text",
      "content-encoding": "plain"
    }
  },
  "empty1": {},
  "empty2": [],
  "wrapper": {
    "empty3": {},
    "emtpy4": []
  }
}

mlr --ixtab --ojson unflatten -s . -f res ./reg-test/input/unflatten-input.xtab
{
  "hostname": "localhost",
  "pid": 12345,
  "req": {
    "id": 6789,
    "method": "GET",
    "path": "api/check",
    "host": "foo.bar",
    "headers": {
      "host": "bar.baz",
      "user-agent": "browser"
    }
  },
  "res": {
    "status_code": 200,
    "header": {
      "content-type": "text",
      "content-encoding": "plain"
    }
  },
  "empty1": {},
  "empty2": [],
  "wrapper": {
    "empty3": {},
    "emtpy4": []
  }
}

mlr --ixtab --ojson unflatten -s . -f req,res ./reg-test/input/unflatten-input.xtab
{
  "hostname": "localhost",
  "pid": 12345,
  "req": {
    "id": 6789,
    "method": "GET",
    "path": "api/check",
    "host": "foo.bar",
    "headers": {
      "host": "bar.baz",
      "user-agent": "browser"
    }
  },
  "res": {
    "status_code": 200,
    "header": {
      "content-type": "text",
      "content-encoding": "plain"
    }
  },
  "empty1": {},
  "empty2": [],
  "wrapper": {
    "empty3": {},
    "emtpy4": []
  }
}

mlr --ixtab --ojson unflatten -s . -f nonesuch,res ./reg-test/input/unflatten-input.xtab
{
  "hostname": "localhost",
  "pid": 12345,
  "req": {
    "id": 6789,
    "method": "GET",
    "path": "api/check",
    "host": "foo.bar",
    "headers": {
      "host": "bar.baz",
      "user-agent": "browser"
    }
  },
  "res": {
    "status_code": 200,
    "header": {
      "content-type": "text",
      "content-encoding": "plain"
    }
  },
  "empty1": {},
  "empty2": [],
  "wrapper": {
    "empty3": {},
    "emtpy4": []
  }
}

mlr --j2x cat ./reg-test/input/flatten-input-2.json
hostname                    localhost
pid                         12345
req.id                      6789
req.method                  GET
req.path                    api/check
req.host                    foo.bar
req.headers.host            bar.baz
req.headers.user-agent      browser
res.status_code             200
res.header.content-type     text
res.header.content-encoding plain
empty1                      {}
empty2                      []
wrapper.empty3              {}
wrapper.emtpy4              []

mlr --x2j cat
{
  "hostname": "localhost",
  "pid": 12345,
  "req": {
    "id": 6789,
    "method": "GET",
    "path": "api/check",
    "host": "foo.bar",
    "headers": {
      "host": "bar.baz",
      "user-agent": "browser"
    }
  },
  "res": {
    "status_code": 200,
    "header": {
      "content-type": "text",
      "content-encoding": "plain"
    }
  },
  "empty1": {},
  "empty2": [],
  "wrapper": {
    "empty3": {},
    "emtpy4": []
  }
}

