Documentation ¶
Index ¶
- Variables
- type Neatjson
- func (N *Neatjson) B(v interface{}) ([]byte, error)
- func (N *Neatjson) B2S(data []byte) (string, error)
- func (N *Neatjson) BxB(data []byte) ([]byte, error)
- func (N *Neatjson) BxS(data string) ([]byte, error)
- func (N *Neatjson) Bytes(v interface{}) ([]byte, error)
- func (N *Neatjson) Must() *Neatjson_Must
- func (N *Neatjson) Omit() *Neatjson_Omit
- func (N *Neatjson) S(v interface{}) (string, error)
- func (N *Neatjson) S2B(data string) ([]byte, error)
- func (N *Neatjson) Sjson(v interface{}) (string, error)
- func (N *Neatjson) Soft() *Neatjson_Soft
- func (N *Neatjson) SxB(data []byte) (string, error)
- func (N *Neatjson) SxS(s string) (string, error)
- type Neatjson_Must
- func (T *Neatjson_Must) B(v interface{}) (res []byte)
- func (T *Neatjson_Must) B2S(data []byte) (res string)
- func (T *Neatjson_Must) BxB(data []byte) (res []byte)
- func (T *Neatjson_Must) BxS(data string) (res []byte)
- func (T *Neatjson_Must) Bytes(v interface{}) (res []byte)
- func (T *Neatjson_Must) S(v interface{}) (res string)
- func (T *Neatjson_Must) S2B(data string) (res []byte)
- func (T *Neatjson_Must) Sjson(v interface{}) (res string)
- func (T *Neatjson_Must) SxB(data []byte) (res string)
- func (T *Neatjson_Must) SxS(s string) (res string)
- type Neatjson_Omit
- func (T *Neatjson_Omit) B(v interface{}) (res []byte)
- func (T *Neatjson_Omit) B2S(data []byte) (res string)
- func (T *Neatjson_Omit) BxB(data []byte) (res []byte)
- func (T *Neatjson_Omit) BxS(data string) (res []byte)
- func (T *Neatjson_Omit) Bytes(v interface{}) (res []byte)
- func (T *Neatjson_Omit) S(v interface{}) (res string)
- func (T *Neatjson_Omit) S2B(data string) (res []byte)
- func (T *Neatjson_Omit) Sjson(v interface{}) (res string)
- func (T *Neatjson_Omit) SxB(data []byte) (res string)
- func (T *Neatjson_Omit) SxS(s string) (res string)
- type Neatjson_Soft
- func (T *Neatjson_Soft) B(v interface{}) (res []byte)
- func (T *Neatjson_Soft) B2S(data []byte) (res string)
- func (T *Neatjson_Soft) BxB(data []byte) (res []byte)
- func (T *Neatjson_Soft) BxS(data string) (res []byte)
- func (T *Neatjson_Soft) Bytes(v interface{}) (res []byte)
- func (T *Neatjson_Soft) S(v interface{}) (res string)
- func (T *Neatjson_Soft) S2B(data string) (res []byte)
- func (T *Neatjson_Soft) Sjson(v interface{}) (res string)
- func (T *Neatjson_Soft) SxB(data []byte) (res string)
- func (T *Neatjson_Soft) SxS(s string) (res string)
Constants ¶
This section is empty.
Variables ¶
var ( TAB = NewNeatjson("", "\t") SP0 = NewNeatjson("", "") SP1 = NewNeatjson("", " ") SP2 = NewNeatjson("", " ") SP3 = NewNeatjson("", " ") SP4 = NewNeatjson("", " ") NOI = notNeatjson() //在转json时结果不换行 NON = notNeatjson() //在转json时结果不换行 )
这里定义些 常用常量 以便于外部直接使用
Functions ¶
This section is empty.
Types ¶
type Neatjson ¶
type Neatjson struct {
// contains filtered or unexported fields
}
Neatjson implements various syntactic sugar to convert Go structs into JSON strings. The purpose of this package is to provide neat, indented JSON representations. Neatjson 实现了一些简单的语法糖,用于将 Go 的结构体转换为 JSON 字符串。 neat 的含义包括:整齐的、工整的、简洁的、整洁的。
func NewNeatjson ¶
NewNeatjson creates a new instance of Neatjson with the specified prefix and indent. NewNeatjson 根据指定的前缀和缩进字符创建一个 Neatjson 实例。
func (*Neatjson) B2S ¶
B2S converts JSON bytes into a neat JSON string. "2" means "to". B2S 将 JSON 字节数组转换为整齐的 JSON 字符串。"2" 表示 "to"。
func (*Neatjson) BxB ¶
BxB converts a JSON byte array into a neat JSON byte array with the desired formatting. BxB 将 JSON 字节数组转换为符合要求格式的整齐 JSON 字节数组。
func (*Neatjson) BxS ¶
BxS converts a JSON string into a neat JSON byte array. "x" means "from". BxS 将 JSON 字符串转换为整齐的 JSON 字节数组。"x" 表示 "from"。
func (*Neatjson) Bytes ¶
Bytes converts a struct to a JSON byte array, similar to "json.Marshal" but supports indentation. Bytes 将结构体转换为 JSON 字节数组,与 "json.Marshal" 类似,但支持缩进。
func (*Neatjson) Must ¶
func (N *Neatjson) Must() *Neatjson_Must
func (*Neatjson) Omit ¶
func (N *Neatjson) Omit() *Neatjson_Omit
func (*Neatjson) S2B ¶
S2B converts a JSON string into a neat JSON byte array. "2" means "to". S2B 将 JSON 字符串转换为整齐的 JSON 字节数组。"2" 表示 "to"。
func (*Neatjson) Sjson ¶
Sjson converts a struct to a JSON string with the desired formatting. Sjson 将结构体转换为符合要求格式的 JSON 字符串。
func (*Neatjson) Soft ¶
func (N *Neatjson) Soft() *Neatjson_Soft
type Neatjson_Must ¶
type Neatjson_Must struct{ N *Neatjson }
func (*Neatjson_Must) B ¶
func (T *Neatjson_Must) B(v interface{}) (res []byte)
func (*Neatjson_Must) B2S ¶
func (T *Neatjson_Must) B2S(data []byte) (res string)
func (*Neatjson_Must) BxB ¶
func (T *Neatjson_Must) BxB(data []byte) (res []byte)
func (*Neatjson_Must) BxS ¶
func (T *Neatjson_Must) BxS(data string) (res []byte)
func (*Neatjson_Must) Bytes ¶
func (T *Neatjson_Must) Bytes(v interface{}) (res []byte)
func (*Neatjson_Must) S ¶
func (T *Neatjson_Must) S(v interface{}) (res string)
func (*Neatjson_Must) S2B ¶
func (T *Neatjson_Must) S2B(data string) (res []byte)
func (*Neatjson_Must) Sjson ¶
func (T *Neatjson_Must) Sjson(v interface{}) (res string)
func (*Neatjson_Must) SxB ¶
func (T *Neatjson_Must) SxB(data []byte) (res string)
func (*Neatjson_Must) SxS ¶
func (T *Neatjson_Must) SxS(s string) (res string)
type Neatjson_Omit ¶
type Neatjson_Omit struct{ N *Neatjson }
func (*Neatjson_Omit) B ¶
func (T *Neatjson_Omit) B(v interface{}) (res []byte)
func (*Neatjson_Omit) B2S ¶
func (T *Neatjson_Omit) B2S(data []byte) (res string)
func (*Neatjson_Omit) BxB ¶
func (T *Neatjson_Omit) BxB(data []byte) (res []byte)
func (*Neatjson_Omit) BxS ¶
func (T *Neatjson_Omit) BxS(data string) (res []byte)
func (*Neatjson_Omit) Bytes ¶
func (T *Neatjson_Omit) Bytes(v interface{}) (res []byte)
func (*Neatjson_Omit) S ¶
func (T *Neatjson_Omit) S(v interface{}) (res string)
func (*Neatjson_Omit) S2B ¶
func (T *Neatjson_Omit) S2B(data string) (res []byte)
func (*Neatjson_Omit) Sjson ¶
func (T *Neatjson_Omit) Sjson(v interface{}) (res string)
func (*Neatjson_Omit) SxB ¶
func (T *Neatjson_Omit) SxB(data []byte) (res string)
func (*Neatjson_Omit) SxS ¶
func (T *Neatjson_Omit) SxS(s string) (res string)
type Neatjson_Soft ¶
type Neatjson_Soft struct{ N *Neatjson }
func (*Neatjson_Soft) B ¶
func (T *Neatjson_Soft) B(v interface{}) (res []byte)
func (*Neatjson_Soft) B2S ¶
func (T *Neatjson_Soft) B2S(data []byte) (res string)
func (*Neatjson_Soft) BxB ¶
func (T *Neatjson_Soft) BxB(data []byte) (res []byte)
func (*Neatjson_Soft) BxS ¶
func (T *Neatjson_Soft) BxS(data string) (res []byte)
func (*Neatjson_Soft) Bytes ¶
func (T *Neatjson_Soft) Bytes(v interface{}) (res []byte)
func (*Neatjson_Soft) S ¶
func (T *Neatjson_Soft) S(v interface{}) (res string)
func (*Neatjson_Soft) S2B ¶
func (T *Neatjson_Soft) S2B(data string) (res []byte)
func (*Neatjson_Soft) Sjson ¶
func (T *Neatjson_Soft) Sjson(v interface{}) (res string)
func (*Neatjson_Soft) SxB ¶
func (T *Neatjson_Soft) SxB(data []byte) (res string)
func (*Neatjson_Soft) SxS ¶
func (T *Neatjson_Soft) SxS(s string) (res string)