Documentation ¶
Overview ¶
Package jsoncolor is a replacement for encoding/json's Marshal and MarshalIndent producing colorized output.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultSpaceColor = color.New() DefaultCommaColor = color.New(color.Bold) DefaultColonColor = color.New(color.Bold) DefaultObjectColor = color.New(color.Bold) DefaultArrayColor = color.New(color.Bold) DefaultFieldQuoteColor = color.New(color.FgBlue, color.Bold) DefaultFieldColor = color.New(color.FgBlue, color.Bold) DefaultStringQuoteColor = color.New(color.FgGreen) DefaultStringColor = color.New(color.FgGreen) DefaultTrueColor = color.New() DefaultFalseColor = color.New() DefaultNumberColor = color.New() DefaultNullColor = color.New(color.FgBlack, color.Bold) // By default, no prefix is used. DefaultPrefix = "" // By default, an indentation of two spaces is used. DefaultIndent = " " )
Functions ¶
func MarshalIndent ¶
MarshalIndent is like encoding/json's MarshalIndent but colorizes the output.
Types ¶
type Formatter ¶
type Formatter struct { // Color for whitespace characters. SpaceColor SprintfFuncer // Color for comma character ',' delimiting object and array // fields. CommaColor SprintfFuncer // Color for colon character ':' separating object field names // and values. ColonColor SprintfFuncer // Color for object delimiter characters '{' and '}'. ObjectColor SprintfFuncer // Color for array delimiter characters '[' and ']'. ArrayColor SprintfFuncer // Color for quotes '" surrounding object field names. FieldQuoteColor SprintfFuncer // Color for object field names. FieldColor SprintfFuncer // Color for quotes '"' surrounding string values. StringQuoteColor SprintfFuncer // Color for string values. StringColor SprintfFuncer // Color for 'true' boolean values. TrueColor SprintfFuncer // Color for 'false' boolean values. FalseColor SprintfFuncer // Color for number values. NumberColor SprintfFuncer // Color for null values. NullColor SprintfFuncer // Prefix is prepended before indentation to newlines. Prefix string // Indent is prepended to newlines one or more times according // to indentation nesting. Indent string // EscapeHTML specifies whether problematic HTML characters // should be escaped inside JSON quoted strings. See // json.Encoder.SetEscapeHTML's comment for more details. EscapeHTML bool }
Formatter colorizes buffers containing JSON.
type SprintfFuncer ¶
Click to show internal directories.
Click to hide internal directories.