go-text: github.com/mithrandie/go-text/json Index | Files

package json

import "github.com/mithrandie/go-text/json"

Package csv is a Go library to read and write JSON format.

Index

Package Files

decoder.go encoder.go lexer.go main.go parser.go scanner.go string.go structure.go types.go

Constants

const (
    BeginArray     = '['
    BeginObject    = '{'
    EndArray       = ']'
    EndObject      = '}'
    NameSeparator  = ':'
    ValueSeparator = ','
    QuotationMark  = '"'
    EscapeMark     = '\\'
)
const (
    FalseValue = "false"
    TrueValue  = "true"
    NullValue  = "null"
)
const (
    ObjectKeyEffect = "json_object_key"
    StringEffect    = "json_string"
    NumberEffect    = "json_number"
    BooleanEffect   = "json_boolean"
    NullEffect      = "json_null"
)
const BOOLEAN = 57348
const EOF = -1
const FLOAT = 57350
const INTEGER = 57351
const NULL = 57349
const NUMBER = 57346
const STRING = 57347

Variables

var WhiteSpaces = []rune{
    32,
    9,
    10,
    13,
}

func EncodeRune Uses

func EncodeRune(r rune) []byte

func Escape Uses

func Escape(s string) string

func EscapeAll Uses

func EscapeAll(s string) string

func EscapeWithHexDigits Uses

func EscapeWithHexDigits(s string) string

func GetEscapeBuf Uses

func GetEscapeBuf() *bytes.Buffer

func NewJsonPalette Uses

func NewJsonPalette() *color.Palette

func NewSyntaxError Uses

func NewSyntaxError(message string, token Token) error

func ParseJson Uses

func ParseJson(src string, useInteger bool) (Structure, EscapeType, error)

func PutEscapeBuf Uses

func PutEscapeBuf(b *bytes.Buffer)

func Quote Uses

func Quote(s string) string

type Array Uses

type Array []Structure

func (Array) Encode Uses

func (ar Array) Encode() string

type Boolean Uses

type Boolean bool

func (Boolean) Encode Uses

func (b Boolean) Encode() string

func (Boolean) Raw Uses

func (b Boolean) Raw() bool

type Decoder Uses

type Decoder struct {
    // Returns numeric values as Integer or Float instead of Number if true.
    UseInteger bool
}

func NewDecoder Uses

func NewDecoder() *Decoder

func (Decoder) Decode Uses

func (d Decoder) Decode(src string) (Structure, EscapeType, error)

type Encoder Uses

type Encoder struct {
    EscapeType   EscapeType
    PrettyPrint  bool
    LineBreak    text.LineBreak
    IndentSpaces int
    Palette      *color.Palette
    // contains filtered or unexported fields
}

func NewEncoder Uses

func NewEncoder() *Encoder

func (*Encoder) Encode Uses

func (e *Encoder) Encode(structure Structure) string

type EscapeType Uses

type EscapeType int
const (
    Backslash        EscapeType = 0
    HexDigits        EscapeType = 1
    AllWithHexDigits EscapeType = 2
)

func Unescape Uses

func Unescape(s string) (string, EscapeType)

type Float Uses

type Float float64

func (Float) Encode Uses

func (n Float) Encode() string

func (Float) Raw Uses

func (n Float) Raw() float64

type Integer Uses

type Integer int64

func (Integer) Encode Uses

func (n Integer) Encode() string

func (Integer) Raw Uses

func (n Integer) Raw() int64

type Lexer Uses

type Lexer struct {
    Scanner
    // contains filtered or unexported fields
}

func (*Lexer) Error Uses

func (l *Lexer) Error(e string)

func (*Lexer) Lex Uses

func (l *Lexer) Lex(lval *yySymType) int

type Null Uses

type Null struct{}

func (Null) Encode Uses

func (n Null) Encode() string

type Number Uses

type Number float64

func (Number) Encode Uses

func (n Number) Encode() string

func (Number) Raw Uses

func (n Number) Raw() float64

type Object Uses

type Object struct {
    Members []ObjectMember
}

func NewObject Uses

func NewObject(capacity int) Object

func (*Object) Add Uses

func (obj *Object) Add(key string, val Structure)

func (Object) Encode Uses

func (obj Object) Encode() string

func (*Object) Exists Uses

func (obj *Object) Exists(key string) bool

func (*Object) Keys Uses

func (obj *Object) Keys() []string

func (*Object) Len Uses

func (obj *Object) Len() int

func (*Object) Range Uses

func (obj *Object) Range(fn func(key string, value Structure) bool)

func (*Object) Update Uses

func (obj *Object) Update(key string, val Structure)

func (*Object) Value Uses

func (obj *Object) Value(key string) Structure

func (*Object) Values Uses

func (obj *Object) Values() []Structure

type ObjectMember Uses

type ObjectMember struct {
    Key   string
    Value Structure
}

type Scanner Uses

type Scanner struct {
    UseInteger bool
    // contains filtered or unexported fields
}

func (*Scanner) EscapeType Uses

func (s *Scanner) EscapeType() EscapeType

func (*Scanner) Init Uses

func (s *Scanner) Init(src string, useInteger bool) *Scanner

func (*Scanner) Scan Uses

func (s *Scanner) Scan() (Token, error)

type String Uses

type String string

func (String) Encode Uses

func (s String) Encode() string

func (String) Raw Uses

func (s String) Raw() string

type Structure Uses

type Structure interface {
    Encode() string
}

type SyntaxError Uses

type SyntaxError struct {
    Line    int
    Column  int
    Message string
}

func (SyntaxError) Error Uses

func (e SyntaxError) Error() string

type Token Uses

type Token struct {
    Token   int
    Literal string
    Line    int
    Column  int
}

Package json imports 9 packages (graph) and is imported by 3 packages. Updated 2019-10-25. Refresh now. Tools for package owners.