yaml,xml,json数据格式封装解析测试

This commit is contained in:
John
2018-01-19 16:19:48 +08:00
parent fbd8bf9d18
commit 8ecddef8e6
7 changed files with 111 additions and 64 deletions

View File

@ -17,8 +17,12 @@ func Decode(xmlbyte []byte) (map[string]interface{}, error) {
}
// 将map变量解析为XML格式内容
func Encode(v map[string]interface{}) ([]byte, error) {
return mxj.Map(v).Xml()
func Encode(v map[string]interface{}, rootTag...string) ([]byte, error) {
return mxj.Map(v).Xml(rootTag...)
}
func EncodeWithIndent(v map[string]interface{}, rootTag...string) ([]byte, error) {
return mxj.Map(v).XmlIndent("", "\t", rootTag...)
}
// XML格式内容直接转换为JSON格式内容