Golang encoding/json.UnmarshalTypeError type and function example
package encoding/json
An UnmarshalTypeError describes a JSON value that was not appropriate for a value of a specific Go type.
Golang encoding/json.UnmarshalTypeError type and function usage example
switch err.(type) {
case ct.ValidationError:
fmt.Println("Validation error")
case *json.SyntaxError, *json.UnmarshalTypeError:
fmt.Println("The provided JSON input is invalid")
// fmt.Println(err.Error())
default:
fmt.Println(err)
}
Reference :
Advertisement
Something interesting
Tutorials
+26.9k Golang : Force your program to run with root permissions
+10.1k Golang : Identifying Golang HTTP client request
+15.3k Golang : Get query string value on a POST request
+8.3k Swift : Convert (cast) Character to Integer?
+13.4k Golang : Increment string example
+22.7k Golang : Set and Get HTTP request headers example
+11.7k How to tell if a binary(executable) file or web application is built with Golang?
+6k Golang : Function as an argument type example
+22.9k Golang : Calculate time different
+8.8k Golang : Heap sort example
+7k Golang : Levenshtein distance example
+12.3k Golang : Flush and close file created by os.Create and bufio.NewWriter example