Documentation
¶
Overview ¶
Package json is a Go library to read and write JSON format.
Index ¶
- Constants
- Variables
- func EncodeRune(r rune) []byte
- func Escape(s string) string
- func EscapeAll(s string) string
- func EscapeWithHexDigits(s string) string
- func GetEscapeBuf() *bytes.Buffer
- func NewJsonPalette() *color.Palette
- func NewSyntaxError(message string, token Token) error
- func ParseJson(src string, useInteger bool) (Structure, EscapeType, error)
- func PutEscapeBuf(b *bytes.Buffer)
- func Quote(s string) string
- type Array
- type Boolean
- type DecodeError
- type Decoder
- type Encoder
- type EscapeType
- type Float
- type FloatFormat
- type Integer
- type Lexer
- type NanInfHandling
- type Null
- type Number
- type Object
- func (obj *Object) Add(key string, val Structure)
- func (obj Object) Encode() string
- func (obj *Object) Exists(key string) bool
- func (obj *Object) Keys() []string
- func (obj *Object) Len() int
- func (obj *Object) Range(fn func(key string, value Structure) bool)
- func (obj *Object) Update(key string, val Structure)
- func (obj *Object) Value(key string) Structure
- func (obj *Object) Values() []Structure
- type ObjectMember
- type Scanner
- type String
- type Structure
- type SyntaxError
- type Token
- type UnsupportedValueError
Constants ¶
View Source
const ( BeginArray = '[' BeginObject = '{' EndArray = ']' EndObject = '}' NameSeparator = ':' ValueSeparator = ',' QuotationMark = '"' EscapeMark = '\\' )
View Source
const ( FalseValue = "false" TrueValue = "true" NullValue = "null" )
View Source
const ( ObjectKeyEffect = "json_object_key" StringEffect = "json_string" NumberEffect = "json_number" BooleanEffect = "json_boolean" NullEffect = "json_null" )
View Source
const BOOLEAN = 57348
View Source
const EOF = -1
View Source
const FLOAT = 57350
View Source
const INTEGER = 57351
View Source
const NULL = 57349
View Source
const NUMBER = 57346
View Source
const STRING = 57347
Variables ¶
View Source
var WhiteSpaces = []rune{
32,
9,
10,
13,
}
Functions ¶
func EncodeRune ¶
func EscapeWithHexDigits ¶
func GetEscapeBuf ¶
func NewJsonPalette ¶
func NewSyntaxError ¶
func PutEscapeBuf ¶
Types ¶
type DecodeError ¶ added in v1.5.0
type DecodeError struct {
// contains filtered or unexported fields
}
func NewDecodeError ¶ added in v1.5.0
func NewDecodeError(line int, char int, message string) *DecodeError
func (DecodeError) Char ¶ added in v1.5.0
func (e DecodeError) Char() int
func (DecodeError) Error ¶ added in v1.5.0
func (e DecodeError) Error() string
func (DecodeError) Line ¶ added in v1.5.0
func (e DecodeError) Line() int
func (DecodeError) Message ¶ added in v1.5.0
func (e DecodeError) Message() string
type Decoder ¶
type Decoder struct { // Returns numeric values as Integer or Float instead of Number if true. UseInteger bool }
func NewDecoder ¶
func NewDecoder() *Decoder
type Encoder ¶
type Encoder struct { EscapeType EscapeType PrettyPrint bool NanInfHandling NanInfHandling FloatFormat FloatFormat LineBreak text.LineBreak IndentSpaces int Palette *color.Palette // contains filtered or unexported fields }
func NewEncoder ¶
func NewEncoder() *Encoder
type EscapeType ¶
type EscapeType int
const ( Backslash EscapeType = 0 HexDigits EscapeType = 1 AllWithHexDigits EscapeType = 2 )
func Unescape ¶
func Unescape(s string) (string, EscapeType)
type FloatFormat ¶ added in v1.5.4
type FloatFormat int8
const ( NoExponent FloatFormat = iota ENotationForLargeExponents )
type NanInfHandling ¶ added in v1.5.4
type NanInfHandling int8
const ( ConvertToNull NanInfHandling = iota CreateError ConvertToStringNotation )
type Number ¶
type Number float64
func (Number) IsNegativeInfinity ¶ added in v1.5.4
func (Number) IsPositiveInfinity ¶ added in v1.5.4
type ObjectMember ¶
type Scanner ¶
type Scanner struct { UseInteger bool // contains filtered or unexported fields }
func (*Scanner) EscapeType ¶
func (s *Scanner) EscapeType() EscapeType
type SyntaxError ¶
func (SyntaxError) Error ¶
func (e SyntaxError) Error() string
type UnsupportedValueError ¶ added in v1.5.4
type UnsupportedValueError struct {
Value string
}
func NewUnsupportedValueError ¶ added in v1.5.4
func NewUnsupportedValueError(value string) *UnsupportedValueError
func (UnsupportedValueError) Error ¶ added in v1.5.4
func (e UnsupportedValueError) Error() string
Click to show internal directories.
Click to hide internal directories.