Documentation ¶
Overview ¶
数据文件编码/解析.
Index ¶
- func VarToJson(value interface{}) ([]byte, error)
- func VarToJsonIndent(value interface{}) ([]byte, error)
- func VarToStruct(value interface{}, obj interface{}) error
- func VarToToml(value interface{}) ([]byte, error)
- func VarToXml(value interface{}, rootTag ...string) ([]byte, error)
- func VarToXmlIndent(value interface{}, rootTag ...string) ([]byte, error)
- func VarToYaml(value interface{}) ([]byte, error)
- type Parser
- func (p *Parser) Get(pattern string) interface{}
- func (p *Parser) GetArray(pattern string) []interface{}
- func (p *Parser) GetBool(pattern string) bool
- func (p *Parser) GetFloat32(pattern string) float32
- func (p *Parser) GetFloat64(pattern string) float64
- func (p *Parser) GetInt(pattern string) int
- func (p *Parser) GetInt16(pattern string) int16
- func (p *Parser) GetInt32(pattern string) int32
- func (p *Parser) GetInt64(pattern string) int64
- func (p *Parser) GetInt8(pattern string) int8
- func (p *Parser) GetMap(pattern string) map[string]interface{}
- func (p *Parser) GetString(pattern string) string
- func (p *Parser) GetToVar(pattern string, v interface{}) error
- func (p *Parser) GetUint(pattern string) uint
- func (p *Parser) GetUint16(pattern string) uint16
- func (p *Parser) GetUint32(pattern string) uint32
- func (p *Parser) GetUint64(pattern string) uint64
- func (p *Parser) GetUint8(pattern string) uint8
- func (p *Parser) Remove(pattern string) error
- func (p *Parser) Set(pattern string, value interface{}) error
- func (p *Parser) SetSplitChar(char byte)
- func (p *Parser) SetViolenceCheck(check bool)
- func (p *Parser) ToArray() []interface{}
- func (p *Parser) ToJson() ([]byte, error)
- func (p *Parser) ToJsonIndent() ([]byte, error)
- func (p *Parser) ToMap() map[string]interface{}
- func (p *Parser) ToStruct(o interface{}) error
- func (p *Parser) ToToml() ([]byte, error)
- func (p *Parser) ToXml(rootTag ...string) ([]byte, error)
- func (p *Parser) ToXmlIndent(rootTag ...string) ([]byte, error)
- func (p *Parser) ToYaml() ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func VarToJsonIndent ¶
func VarToStruct ¶
func VarToStruct(value interface{}, obj interface{}) error
将变量解析为对应的struct对象,注意传递的参数为struct对象指针
func VarToXmlIndent ¶
Types ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func LoadContent ¶
支持的配置文件格式:xml, json, yaml/yml, toml
func New ¶
func New(values ...interface{}) *Parser
将变量转换为Parser对象进行处理,该变量至少应当是一个map或者array,否者转换没有意义 该参数为非必需参数,默认为创建一个空的Parser对象
func (*Parser) Get ¶
根据约定字符串方式访问json解析数据,参数形如: "items.name.first", "list.0" 返回的结果类型的interface{},因此需要自己做类型转换 如果找不到对应节点的数据,返回nil
func (*Parser) GetFloat32 ¶
func (*Parser) GetFloat64 ¶
func (*Parser) ToJsonIndent ¶
Click to show internal directories.
Click to hide internal directories.