jtlr

package module
v0.0.0-...-db55557 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

README

JSON Tools by Language Recognition

Inspire by stedolan/jq, Created with antlr4.

Try it

go install github.com/xiaoler/jtlr-go/cmd/jtlr

Feature

basic usage:

jtlr '{"a": 1}'

interactive mode:

jtlr -a

read line from stdin:

bash examples/stdout.sh | jtlr -s

read line from file:

jtlr -f examples/json.txt

set indent

jtlr -t "\t" '{"a": 1}'

Documentation

Index

Constants

View Source
const (
	COLOR_Reset        = "\033[0m"
	COLOR_Black        = "\033[0;30m"
	COLOR_Red          = "\033[0;31m"
	COLOR_Green        = "\033[0;32m"
	COLOR_Brown        = "\033[0;33m"
	COLOR_Blue         = "\033[0;34m"
	COLOR_Purple       = "\033[0;35m"
	COLOR_Cyan         = "\033[0;36m"
	COLOR_Light_Gray   = "\033[0;37m"
	COLOR_Dark_Gray    = "\033[1;30m"
	COLOR_Light_Red    = "\033[1;31m"
	COLOR_Light_Green  = "\033[1;32m"
	COLOR_Yellow       = "\033[1;33m"
	COLOR_Light_Blue   = "\033[1;34m"
	COLOR_Light_Purple = "\033[1;35m"
	COLOR_Light_Cyan   = "\033[1;36m"
	COLOR_White        = "\033[1;37m"
)

Variables

View Source
var (
	IDENT_CHAR = strings.Repeat(" ", 4)
	CRLF       = "\r\n"
)

Functions

func AdvancedShell

func AdvancedShell(fn hanlder)

func BasicShell

func BasicShell(fn hanlder)

func PrettyPrint

func PrettyPrint(input string)

Types

type PrettyPrintErrorListener

type PrettyPrintErrorListener struct {
	*antlr.DefaultErrorListener
}

func NewPrettyPrintErrorListener

func NewPrettyPrintErrorListener() *PrettyPrintErrorListener

func (*PrettyPrintErrorListener) SyntaxError

func (c *PrettyPrintErrorListener) SyntaxError(
	recognizer antlr.Recognizer,
	offendingSymbol interface{},
	line,
	column int,
	msg string,
	e antlr.RecognitionException,
)

type PrettyPrintListener

type PrettyPrintListener struct {
	*parser.BaseJSONListener
	// contains filtered or unexported fields
}

func NewPrettyPrintListener

func NewPrettyPrintListener() *PrettyPrintListener

func (*PrettyPrintListener) EnterArray

func (s *PrettyPrintListener) EnterArray(ctx *parser.ArrayContext)

EnterArray is called when production array is entered.

func (*PrettyPrintListener) EnterObject

func (s *PrettyPrintListener) EnterObject(ctx *parser.ObjectContext)

EnterObject is called when production object is entered.

func (*PrettyPrintListener) EnterPair

func (s *PrettyPrintListener) EnterPair(ctx *parser.PairContext)

EnterPair is called when production pair is entered.

func (*PrettyPrintListener) EnterValue

func (s *PrettyPrintListener) EnterValue(ctx *parser.ValueContext)

EnterValue is called when production value is entered.

func (*PrettyPrintListener) ExitArray

func (s *PrettyPrintListener) ExitArray(ctx *parser.ArrayContext)

ExitArray is called when production array is exited.

func (*PrettyPrintListener) ExitJson

func (s *PrettyPrintListener) ExitJson(ctx *parser.JsonContext)

ExitJson is called when production json is exited.

func (*PrettyPrintListener) ExitObject

func (s *PrettyPrintListener) ExitObject(ctx *parser.ObjectContext)

ExitObject is called when production object is exited.

func (*PrettyPrintListener) ExitPair

func (s *PrettyPrintListener) ExitPair(ctx *parser.PairContext)

ExitPair is called when production pair is exited.

func (*PrettyPrintListener) VisitErrorNode

func (s *PrettyPrintListener) VisitErrorNode(node antlr.ErrorNode)

VisitErrorNode is called when an error node is visited.

func (*PrettyPrintListener) VisitTerminal

func (s *PrettyPrintListener) VisitTerminal(node antlr.TerminalNode)

VisitTerminal is called when a terminal node is visited.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL