Merge pull request #983 from coolhihi/master

Update gjson_api_new_load.go to make gjson work when sometimes the xml end with space or `\n`
This commit is contained in:
John Guo
2020-11-12 18:41:36 +08:00
committed by GitHub

View File

@ -228,7 +228,7 @@ func IsValidDataType(dataType string) bool {
func checkDataType(content []byte) string {
if json.Valid(content) {
return "json"
} else if gregex.IsMatch(`^<.+>[\S\s]+<.+>$`, content) {
} else if gregex.IsMatch(`^<.+>[\S\s]+<.+>\s*$`, content) {
return "xml"
} else if !gregex.IsMatch(`[\n\r]*[\s\t\w\-\."]+\s*=\s*"""[\s\S]+"""`, content) && !gregex.IsMatch(`[\n\r]*[\s\t\w\-\."]+\s*=\s*'''[\s\S]+'''`, content) &&
((gregex.IsMatch(`^[\n\r]*[\w\-\s\t]+\s*:\s*".+"`, content) || gregex.IsMatch(`^[\n\r]*[\w\-\s\t]+\s*:\s*\w+`, content)) ||