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
+16.4k Golang : How to implement two-factor authentication?
+5.6k Javascript : How to refresh page with JQuery ?
+19.9k Golang : Count JSON objects and convert to slice/array
+9.8k Golang : Get current, epoch time and display by year, month and day
+13k Swift : Convert (cast) Int to String ?
+13.4k Golang : Read from buffered reader until specific number of bytes
+17.4k Golang : Multi threading or run two processes or more example
+8.6k Golang : Convert(cast) []byte to io.Reader type
+14.4k Golang : Parsing or breaking down URL
+6.5k Golang : Combine slices of complex numbers and operation example
+16.4k CodeIgniter/PHP : Create directory if does not exist example