Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/michurin/jsonpainter
Fuzzy JSON highlighting
https://github.com/michurin/jsonpainter
golang highlight json string syntax-highlighting
Last synced: 4 days ago
JSON representation
Fuzzy JSON highlighting
- Host: GitHub
- URL: https://github.com/michurin/jsonpainter
- Owner: michurin
- License: mit
- Created: 2021-08-08T11:42:21.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-01-21T07:32:36.000Z (12 months ago)
- Last Synced: 2024-01-21T08:29:11.790Z (12 months ago)
- Topics: golang, highlight, json, string, syntax-highlighting
- Language: Go
- Homepage:
- Size: 51.8 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fuzzy JSON highlighting
[![build](https://github.com/michurin/jsonpainter/actions/workflows/ci.yaml/badge.svg)](https://github.com/michurin/jsonpainter/actions/workflows/ci.yaml)
[![codecov](https://codecov.io/gh/michurin/jsonpainter/branch/master/graph/badge.svg?token=WHEKURGJZ6)](https://codecov.io/gh/michurin/jsonpainter)
[![go reference](https://pkg.go.dev/badge/github.com/michurin/jsonpainter.svg)](https://pkg.go.dev/github.com/michurin/jsonpainter)
[![play.golang.org](https://shields.io/badge/go.dev-play-089?logo=go&logoColor=white&style=flat)](https://go.dev/play/p/kfpFC9Pm7r6)## Description
In fact, it doesn't perform full JSON parsing. It consider
spaces, quoted strings, brackets (including brackets balance),
colons (in context), commas... In addition,
it emphasizes quoted strings right before colons and mark them
as keys.Thanks to this, it can treat semi-JSON strings like this:
12:00:00 INFO Request: {"msg": "hellow"}, Response: {"ok": true}
## Demo
![JSON painter demo](https://raw.githubusercontent.com/michurin/jsonpainter/demo/demo/demo.png)
You can find [code of this demo](https://raw.githubusercontent.com/michurin/jsonpainter/demo/demo/main.go) in `demo` brunch.
You can also [play with library online](https://go.dev/play/p/kfpFC9Pm7r6).
However, this online sandbox doesn't allow to display colored text.
Instead of painted text it you will show you control sequences ([ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)) as is.## Examples
fmt.Println(paintjson.String(`{"x":12}`))
## Install
go get github.com/michurin/jsonpainter
## Todo
- The library gets to have too much heuristics. It has to be rethinking in terms of full-fledged parser.
- Streaming: obtain `io.Reader`
- CLI tool