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
+32.5k Golang : All update packages with go get command
+11.7k Golang : Transform comma separated string to slice example
+34.1k Golang : Get file last modified date and time
+9.6k Golang : Underscore string example
+5.2k Golang : Convert Chinese UTF8 characters to Pin Yin
+17.1k Golang : Display list of time zones with GMT
+10.8k Golang : Convert(cast) bigint to string
+11.2k Golang : How to parse plain email text and process email header?
+6.1k Golang : How to call function inside template with template.FuncMap
+7.9k Golang : Gonum standard normal random numbers example
+14.4k Golang : Intercept Ctrl-C interrupt or kill signal and determine the signal type
+6.3k Nginx : How to block user agent ?