You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dorm/xml.go

22 lines
500 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package dorm
import (
"encoding/json"
"github.com/basgys/goxml2json"
"strings"
)
// XmlDecodeNoError xml字符串转结构体不报错
func XmlDecodeNoError(b []byte) map[string]interface{} {
xtj := strings.NewReader(string(b))
jtx, _ := xml2json.Convert(xtj)
var data map[string]interface{}
_ = json.Unmarshal(jtx.Bytes(), &data)
return data
}
// XmlEncodeNoError 结构体转json字符串不报错
func XmlEncodeNoError(data interface{}) string {
return JsonEncodeNoError(data)
}