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
+7.9k Javascript : How to check a browser's Do Not Track status?
+23.7k Find and replace a character in a string in Go
+20.3k Golang : Check if os.Stdin input data is piped or from terminal
+15.2k Golang : Accurate and reliable decimal calculations
+7.2k Golang : Check if one string(rune) is permutation of another string(rune)
+6k Javascript : Get operating system and browser information
+17.2k Golang : When to use init() function?
+16.4k Golang : Send email and SMTP configuration example
+15.8k Golang : How to login and logout with JWT example
+13.4k Golang : error parsing regexp: invalid or unsupported Perl syntax
+51.4k Golang : Check if item is in slice/array
+23.1k Golang : simulate tail -f or read last line from log file example