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
+5.4k Golang : What is StructTag and how to get StructTag's value?
+21.8k Golang : Convert string slice to struct and access with reflect example
+8.2k Android Studio : Rating bar example
+14.6k Golang : Reset buffer example
+23.6k Golang : minus time with Time.Add() or Time.AddDate() functions to calculate past date
+19.3k Golang : Calculate entire request body length during run time
+7.4k Golang : Check to see if *File is a file or directory
+22.9k Golang : Calculate time different
+5.4k Unix/Linux/MacOSx : How to remove an environment variable ?
+9.4k Golang : Qt Yes No and Quit message box example
+18.5k Golang : Example for RSA package functions