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
+11.5k Golang : Change date format to yyyy-mm-dd
+9k Golang : Capture text return from exec function example
+11.2k Golang : Fix - does not implement sort.Interface (missing Len method)
+6.1k Golang : Debug with Godebug
+4.7k Adding Skype actions such as call and chat into web page examples
+13.5k Facebook PHP getUser() returns 0
+12.1k Golang : convert(cast) string to integer value
+11.1k Golang : How to determine a prime number?
+27.6k PHP : Convert(cast) string to bigInt
+4.9k HTTP common errors and their meaning explained
+87.7k Golang : How to convert character to ASCII and back