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
+6.2k PHP : Get client IP address
+7.4k Golang : How to detect if a sentence ends with a punctuation?
+10.1k Golang : Test a slice of integers for odd and even numbers
+6.6k Golang : Totalize or add-up an array or slice example
+4.8k Which content-type(MIME type) to use for JSON data
+16.6k Golang : Generate QR codes for Google Authenticator App and fix "Cannot interpret QR code" error
+4.6k Javascript : Detect when console is activated and do something about it
+7.8k Swift : Convert (cast) String to Double
+8.1k Golang : HTTP Server Example
+30.4k Golang : How to verify uploaded file is image or allowed file types
+4.9k HTTP common errors and their meaning explained
+22k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."