2019-05-08 22:04:36 +08:00
|
|
|
// Copyright 2017 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
|
|
|
|
//
|
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
|
|
|
|
// You can obtain one at https://gitee.com/johng/gp.
|
|
|
|
|
|
|
|
|
|
package gparser
|
|
|
|
|
|
2019-06-22 17:02:36 +08:00
|
|
|
// MarshalJSON implements the interface MarshalJSON for json.Marshal.
|
|
|
|
|
func (p *Parser) MarshalJSON() ([]byte, error) {
|
|
|
|
|
return p.json.MarshalJSON()
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-19 09:06:52 +08:00
|
|
|
func (p *Parser) ToXml(rootTag ...string) ([]byte, error) {
|
|
|
|
|
return p.json.ToXml(rootTag...)
|
2019-05-08 22:04:36 +08:00
|
|
|
}
|
|
|
|
|
|
2019-06-19 09:06:52 +08:00
|
|
|
func (p *Parser) ToXmlIndent(rootTag ...string) ([]byte, error) {
|
|
|
|
|
return p.json.ToXmlIndent(rootTag...)
|
2019-05-08 22:04:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *Parser) ToJson() ([]byte, error) {
|
2019-06-19 09:06:52 +08:00
|
|
|
return p.json.ToJson()
|
2019-05-08 22:04:36 +08:00
|
|
|
}
|
|
|
|
|
|
2019-05-11 17:56:14 +08:00
|
|
|
func (p *Parser) ToJsonString() (string, error) {
|
|
|
|
|
return p.json.ToJsonString()
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-08 22:04:36 +08:00
|
|
|
func (p *Parser) ToJsonIndent() ([]byte, error) {
|
2019-06-19 09:06:52 +08:00
|
|
|
return p.json.ToJsonIndent()
|
2019-05-08 22:04:36 +08:00
|
|
|
}
|
|
|
|
|
|
2019-05-11 17:56:14 +08:00
|
|
|
func (p *Parser) ToJsonIndentString() (string, error) {
|
|
|
|
|
return p.json.ToJsonIndentString()
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-08 22:04:36 +08:00
|
|
|
func (p *Parser) ToYaml() ([]byte, error) {
|
2019-06-19 09:06:52 +08:00
|
|
|
return p.json.ToYaml()
|
2019-05-08 22:04:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *Parser) ToToml() ([]byte, error) {
|
2019-06-19 09:06:52 +08:00
|
|
|
return p.json.ToToml()
|
2019-05-08 22:04:36 +08:00
|
|
|
}
|
|
|
|
|
|
2019-06-19 09:06:52 +08:00
|
|
|
func VarToXml(value interface{}, rootTag ...string) ([]byte, error) {
|
|
|
|
|
return New(value).ToXml(rootTag...)
|
2019-05-08 22:04:36 +08:00
|
|
|
}
|
|
|
|
|
|
2019-06-19 09:06:52 +08:00
|
|
|
func VarToXmlIndent(value interface{}, rootTag ...string) ([]byte, error) {
|
|
|
|
|
return New(value).ToXmlIndent(rootTag...)
|
2019-05-08 22:04:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func VarToJson(value interface{}) ([]byte, error) {
|
2019-06-19 09:06:52 +08:00
|
|
|
return New(value).ToJson()
|
2019-05-08 22:04:36 +08:00
|
|
|
}
|
|
|
|
|
|
2019-05-11 17:56:14 +08:00
|
|
|
func VarToJsonString(value interface{}) (string, error) {
|
|
|
|
|
return New(value).ToJsonString()
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-08 22:04:36 +08:00
|
|
|
func VarToJsonIndent(value interface{}) ([]byte, error) {
|
2019-05-11 17:56:14 +08:00
|
|
|
return New(value).ToJsonIndent()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func VarToJsonIndentString(value interface{}) (string, error) {
|
|
|
|
|
return New(value).ToJsonIndentString()
|
2019-05-08 22:04:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func VarToYaml(value interface{}) ([]byte, error) {
|
2019-06-19 09:06:52 +08:00
|
|
|
return New(value).ToYaml()
|
2019-05-08 22:04:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func VarToToml(value interface{}) ([]byte, error) {
|
2019-06-19 09:06:52 +08:00
|
|
|
return New(value).ToToml()
|
2019-05-08 22:04:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func VarToStruct(value interface{}, obj interface{}) error {
|
2019-06-19 09:06:52 +08:00
|
|
|
return New(value).ToStruct(obj)
|
2019-05-08 22:04:36 +08:00
|
|
|
}
|