gojson

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2020 License: MIT Imports: 7 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

GoJSON

Json serialization with color, color use of github.com/fatih/color implementation, most of the code from https://github.com/hokaccha/go-prettyjson

Use

go get -v -u github.com/zhcppy/gojson
import (
    "fmt"
    "github.com/zhcppy/gojson"
)

func main() {
    var data = map[string]interface{}{
        "name": "gojson",
    }
    res, err := gojson.Marshal(data)
    if err != nil {
        fmt.Println(err.Error())
        return
    }
    fmt.Println(res)
}

Run shows

git clone https://github.com/zhcppy/gojson
cd gojson
go test -v -test.run Test_Marshal

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(data []byte) (string, error)

func Marshal

func Marshal(v interface{}) (string, error)

func MustMarshal

func MustMarshal(v interface{}) string

Types

type Formatter

type Formatter struct {
	KeyColor        *color.Color
	StringColor     *color.Color
	BoolColor       *color.Color
	NumberColor     *color.Color
	NullColor       *color.Color
	StringMaxLength int
	DisabledColor   bool
	Indent          int
	Newline         string
}

func NewFormatter

func NewFormatter() *Formatter

func (*Formatter) Format

func (f *Formatter) Format(data []byte) (string, error)

func (*Formatter) Marshal

func (f *Formatter) Marshal(v interface{}) (string, error)

Jump to

Keyboard shortcuts

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