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
+21.8k SSL : How to check if current certificate is sha1 or sha2
+7.1k Golang : Gorrila mux.Vars() function example
+11.2k Golang : Fix - does not implement sort.Interface (missing Len method)
+8.4k PHP : How to parse ElasticSearch JSON ?
+12.7k Golang : zlib compress file example
+5.2k Golang : Customize scanner.Scanner to treat dash as part of identifier
+14.4k Golang : Find network of an IP address
+6.5k Golang : Spell checking with ispell example
+9.7k Golang : Load ASN1 encoded DSA public key PEM file example
+5.4k Golang : Intercept, inject and replay HTTP traffics from web server
+7k Golang : Gargish-English language translator