json

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type GuessData

type GuessData struct {
	// contains filtered or unexported fields
}

func Guess

func Guess(b bytes.Bytes) *GuessData

func (GuessData) IsArray

func (g GuessData) IsArray() bool

func (GuessData) IsBoolean

func (g GuessData) IsBoolean() bool

func (*GuessData) IsFloat

func (g *GuessData) IsFloat() bool

func (*GuessData) IsInteger

func (g *GuessData) IsInteger() bool

func (GuessData) IsNull

func (g GuessData) IsNull() bool

func (GuessData) IsObject

func (g GuessData) IsObject() bool

func (GuessData) IsShortcut

func (g GuessData) IsShortcut() bool

func (GuessData) IsString

func (g GuessData) IsString() bool

func (GuessData) JsonType

func (g GuessData) JsonType() Type

func (GuessData) LiteralJsonType

func (g GuessData) LiteralJsonType() Type

func (*GuessData) Number

func (g *GuessData) Number() (*Number, error)

type Number

type Number struct {
	// contains filtered or unexported fields
}

Number provides a method to work with numbers in the understanding of JSON (for example -1.2 e+3).

func NewNumber

func NewNumber(b bytes.Bytes) (*Number, error)

func (Number) Cmp

func (n Number) Cmp(nn *Number) int

Cmp compares the numbers represented by n and nn and returns:

-1 if n <  nn
 0 if n == nn
+1 if n >  nn.

func (Number) Equal

func (n Number) Equal(nn *Number) bool

Equal returns whether the numbers represented by n and nn are equal.

func (Number) GreaterThan

func (n Number) GreaterThan(nn *Number) bool

GreaterThan (GT) returns true when n is greater than nn.

func (Number) GreaterThanOrEqual

func (n Number) GreaterThanOrEqual(nn *Number) bool

GreaterThanOrEqual (GTE) returns true when n is greater than or equal to nn.

func (Number) LengthOfFractionalPart

func (n Number) LengthOfFractionalPart() uint

func (Number) LessThan

func (n Number) LessThan(nn *Number) bool

LessThan (LT) returns true when n is less than nn.

func (Number) LessThanOrEqual

func (n Number) LessThanOrEqual(nn *Number) bool

LessThanOrEqual (LTE) returns true when n is less than or equal to nn.

func (Number) String

func (n Number) String() string

func (Number) ToFloat

func (n Number) ToFloat() float64

type Type

type Type uint8
const (
	// TypeUndefined default value for literal and mixed nodes.
	TypeUndefined Type = iota
	TypeObject
	TypeArray
	TypeString
	TypeInteger
	// TypeFloat to be precise, there is no separate "Integer" and "Float" in JSON,
	// there is a single "Number" type. But in our case, we will assume that there is.
	TypeFloat
	TypeBoolean
	TypeNull

	// TypeMixed indicates that here can be anything.
	TypeMixed
)

func NewJsonType

func NewJsonType(b bytes.Bytes) Type

func (Type) IsLiteralType

func (t Type) IsLiteralType() bool

func (Type) String

func (t Type) String() string

func (Type) ToTokenType

func (t Type) ToTokenType() string

Jump to

Keyboard shortcuts

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