Golang encoding/json.SyntaxError type and function example
package encoding/json
A SyntaxError is a description of a JSON syntax error.
Golang encoding/json.SyntaxError type and function usage example
if err != nil {
switch err.(type) {
case *json.SyntaxError, *json.InvalidUTF8Error: // <--- here
fmt.Printf("invalid json response: %s\n", err)
default:
fmt.Printf("Error: %s\n", err)
}
Reference :
Advertisement
Something interesting
Tutorials
+25.4k Golang : Convert long hexadecimal with strconv.ParseUint example
+8k Findstr command the Grep equivalent for Windows
+14.2k Elastic Search : Mapping date format and sort by date
+18.6k Golang : Find IP address from string
+11.3k Golang : How to use if, eq and print properly in html template
+4.5k Java : Generate multiplication table example
+10k Golang : Convert octal value to string to deal with leading zero problem
+19.9k Golang : How to get time from unix nano example
+14.2k Golang : Fix image: unknown format error
+6.2k Golang : Get missing location after unmarshal binary and gob decode time.