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
+8.8k Golang : Random integer with rand.Seed() within a given range
+13.9k Golang : How to determine if a year is leap year?
+7.9k Swift : Convert (cast) String to Float
+8.4k PHP : How to parse ElasticSearch JSON ?
+19.5k Golang : Example for DSA(Digital Signature Algorithm) package functions
+4.6k MariaDB/MySQL : How to get version information
+8.1k Golang : Multiplexer with net/http and map
+9.5k Golang : Convert(cast) string to int64
+14.4k Golang : Find network of an IP address
+11.6k Golang : Surveillance with web camera and OpenCV
+10.6k Golang : How to delete element(data) from map ?
+25.6k Golang : convert rune to integer value