The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

jl - Show JSON Log Nicely

SYNOPSIS

The jl command allows you to recursively decode JSON in JSON string

    $ echo '{"foo":"{\"bar\":\"{\\\"baz\\\":123}\"}"}' | jl
    {
       "foo" : {
          "bar" : {
             "baz" : 123
          }
       }
    }

OPTIONS

x

If you set x option, then JSON values and parsed elements are split as array by [\t\n\r] before/after recursive JSON decoding.

This option is useful for below case:

    $ echo '{"message":"[05/09/2019 23:51:51]\t[warn]\t{\"foo\":\"bar\"}"}' | jl -x
    {
       "message" : [
          "[05/09/2019 23:51:51]",
          "[warn]",
          {
             "foo" : "bar"
          }
       ]
    }

TAB delimited string has been arraynized. It's easy to treat by c<jq>.

xx

If you set xx option, then the elements are split as array by comma after recursive JSON decoding.

This option is useful for below case:

    $ echo '{"message":"[05/09/2019 23:51:51] foo, bar, baz \n{\"foo\":\"bar\"}\n"}' | jl -xx
    {
       "message" : [
          [
             "[05/09/2019 23:51:51] foo",
             "bar",
             "baz "
          ],
          {
             "foo" : "bar"
          }
       ]
    }

xxx

If you set xxx option, then the elements are split as array without delimiter by each parenthesis and brackets (exclude braces {}) after recursive JSON decoding.

This option is useful for below case:

    $ echo '{"message":"[05/09/2019 23:51:51](warn)<server> \n{\"foo\":\"bar\"}\n"}' | jl -xxx
    {
       "message" : [
          [
             "[05/09/2019 23:51:51]",
             "(warn)",
             "<server>",
             " "
          ],
          {
             "foo" : "bar"
          }
       ]
    }

xxxx

If you set xxxx option, then the elements such like a unix timestamp are converted as local date time after recursive JSON decoding.

This option is useful for below case:

    $ echo '{"message":"[05/09/2019 23:51:51](warn)<server> \n{\"time\":1560026367123}"}' | jl -xxxx
    {
       "message" : [
          [
             "[05/09/2019 23:51:51]",
             "(warn)",
             "<server>",
             " "
          ],
          {
             "time" : "2019-06-09 05:39:27.123"
          }
       ]
    }

NOTE that if you set xxxx option, then it means that x, xx and xxx are enabled as well. xxx is going to be enabled x and xx as well. So xx is including x.

timestamp-key

You can set custom timestamp-key to convert unix timestamp to date time.

    $ echo '{"message":"{\"ts\":1560026367123}"}' | jl --timestamp-key ts
    {
       "message" : {
          "ts" : "2019-06-09 05:39:27.123"
       }
    }

Supports unixtime 1560026367, msec 1560026367123 and 1560026367.123

gmtime

If you set gmtime flag, then unix timestamp converts date time as GMT instead of localtime.

depth

The number of recursive depth. (default: 10)

no-pretty

If set no-pretty option, then output JSON is not prettify. (default: false, Do prettify)

AUTHOR

Dai Okabayashi <bayashi@cpan.org>

SEE ALSO

App::jl

LICENSE

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.