Description
jsoncolor is a drop-in replacement for encoding/json's Marshal and MarshalIndent functions which produce colorized output using fatih's color package.
jsoncolor alternatives and similar packages
Based on the "Specific Formats" category.
Alternatively, view jsoncolor alternatives based on common mentions on social networks and blogs.
-
bluemonday
bluemonday: a fast golang HTML sanitizer (inspired by the OWASP Java HTML Sanitizer) to scrub user generated content of XSS -
omniparser
omniparser: a native Golang ETL streaming parser and transform library for CSV, JSON, XML, EDI, text, etc. -
html-to-markdown
โ๏ธ Convert HTML to Markdown. Even works with entire websites and can be extended through rules. -
mxj
Decode / encode XML to/from map[string]interface{} (or JSON); extract values with dot-notation paths and wildcards. Replaces x2j and j2x packages. -
go-pkg-rss
DISCONTINUED. This package reads RSS and Atom feeds and provides a caching mechanism that adheres to the feed specs. -
goq
A declarative struct-tag-based HTML unmarshaling or scraping package for Go built on top of the goquery library -
github_flavored_markdown
GitHub Flavored Markdown renderer with fenced code block highlighting, clickable header anchor links. -
go-pkg-xmlx
DISCONTINUED. Extension to the standard Go XML package. Maintains a node tree that allows forward/backwards browsing and exposes some simple single/multi-node search functions. -
pagser
Pagser is a simple, extensible, configurable parse and deserialize html page to struct based on goquery and struct tags for golang crawler -
csvplus
csvplus extends the standard Go encoding/csv package with fluent interface, lazy stream operations, indices and joins.
InfluxDB - Purpose built for real-time analytics at any scale.
Do you think we are missing an alternative of jsoncolor or a related project?
README
jsoncolor
jsoncolor
is a drop-in replacement for encoding/json
's Marshal
and MarshalIndent
functions and Encoder
type which produce
colorized output using fatih's color
package.
Installation
go get -u github.com/nwidger/jsoncolor
Usage
To use as a replacement for encoding/json
, exchange
import "encoding/json"
with import json "github.com/nwidger/jsoncolor"
.
json.Marshal
, json.MarshalIndent
and json.NewEncoder
will now
produce colorized output.
Custom Colors
The colors used for each type of token can be customized by creating a
custom Formatter
, changing its XXXColor
fields and then passing it
to MarshalWithFormatter
, MarshalIndentWithFormatter
or
NewEncoderWithFormatter
. If a XXXColor
field of the custom
Formatter
is not set, the corresponding DefaultXXXColor
package
variable is used. See
color.New for creating
custom color values and the
GoDocs
for the default colors.
import (
"fmt"
"log"
"github.com/fatih/color"
json "github.com/nwidger/jsoncolor"
)
// create custom formatter
f := json.NewFormatter()
// set custom colors
f.StringColor = color.New(color.FgBlack, color.Bold)
f.TrueColor = color.New(color.FgWhite, color.Bold)
f.FalseColor = color.New(color.FgRed)
f.NumberColor = color.New(color.FgWhite)
f.NullColor = color.New(color.FgWhite, color.Bold)
// marshal v with custom formatter,
// dst contains colorized output
dst, err := json.MarshalWithFormatter(v, f)
if err != nil {
log.Fatal(err)
}
// print colorized output to stdout
fmt.Println(string(dst))