An open API service indexing awesome lists of open source software.

https://github.com/bayashi/go-jl

`go-jl` provides recursive JSON decorder to show the "JSON within JSON" log nicely
https://github.com/bayashi/go-jl

cli command-line-tool golang json log logging tool viewer

Last synced: 10 months ago
JSON representation

`go-jl` provides recursive JSON decorder to show the "JSON within JSON" log nicely

Awesome Lists containing this project

README

          

# go-jl

MIT License
go-jl CI
go-jl report card
Go Reference: go-jl

Show the "JSON within JSON" log nicely

## Usage

`jl` command recursively converts JSON within JSON into one JSON structure.

Simple case:

```
$ cat simple.json
{
"foo": "{\"bar\":\"{\\\"baz\\\":123}\"}"
}

$ cat simple.json | jl
{
"foo": {
"bar": {
"baz": 123
}
}
}
```

Most use cases:

```
$ cat log.json
{
"message": "{\"level\":\"info\",\"ts\":1557004280.5372975,\"caller\":\"zap/server_interceptors.go:40\",\"msg\":\"finished unary call with code OK\",\"grpc.start_time\":\"2019-05-04T21:11:20Z\",\"system\":\"grpc\",\"span.kind\":\"server\",\"grpc.service\":\"FooService\",\"grpc.method\":\"GetBar\",\"grpc.code\":\"OK\",\"grpc.time_ms\":248.45199584960938}\n",
"namespace": "foo-service",
"podName": "foo-86495899d8-m2vfl",
"containerName": "foo-service"
}

$ cat log.json | jl
{
"containerName": "foo-service",
"message": {
"caller": "zap/server_interceptors.go:40",
"grpc.code": "OK",
"grpc.method": "GetBar",
"grpc.service": "FooService",
"grpc.start_time": "2019-05-04T21:11:20Z",
"grpc.time_ms": 248.45199584960938,
"level": "info",
"msg": "finished unary call with code OK",
"span.kind": "server",
"system": "grpc",
"ts": 1557004280.5372975
},
"namespace": "foo-service",
"podName": "foo-86495899d8-m2vfl"
}

```

Full options:

```
Options:
-h, --help Display help (This message) and exit
-P, --no-prettify Not prettify the JSON. Prettified by default
-e, --show-error Set this option to show errors, muted by default
--skip int Skip to parse JSON if the length of the source JSON less than this
-n, --split-lf Split line-feed \n in each element
-t, --split-tab Split tabs in each element
-v, --version Display version and build info and exit
```

## Installation

### homebrew install

If you are using Mac:

```cmd
brew tap bayashi/tap
brew install bayashi/tap/go-jl
```

### binary install

Download binary from here: https://github.com/bayashi/go-jl/releases

### go install

If you have golang envvironment:

```cmd
go install github.com/bayashi/go-jl/cmd/jl@latest
```

## License

MIT License

## Author

Dai Okabayashi: https://github.com/bayashi