improve package gjson for automatic content type checking

This commit is contained in:
Jack 2020-08-11 23:22:09 +08:00
parent ed479e2a13
commit eacad9b453

View File

@ -207,7 +207,8 @@ func checkDataType(content []byte) string {
return "json"
} else if gregex.IsMatch(`^<.+>[\S\s]+<.+>$`, content) {
return "xml"
} else if gregex.IsMatch(`[\s\t\n]*[\w\-]+\s*:\s*.+`, content) {
} else if gregex.IsMatch(`[\s\t\n]*[\w\-]+\s*:\s*".+"`, content) ||
gregex.IsMatch(`[\s\t\n]*[\w\-]+\s*:\s*\w+`, content) {
return "yml"
} else if gregex.IsMatch(`\[[\w]+\]`, content) &&
gregex.IsMatch(`[\s\t\n\[\]]*[\w\-]+\s*=\s*.+`, content) &&