Commit 96a7282c authored by Simon Schürg's avatar Simon Schürg 🚀
Browse files

add IsJson() method

parent 79a4e0b2
......@@ -32,3 +32,9 @@ func PrettyPrintDecodedJWT(token string) {
fmt.Println("Payload:")
PrettyPrintJSON(claims.Raw)
}
// IsJSON tells whether a given string is valid JSON
func IsJSON(str string) bool {
var js json.RawMessage
return json.Unmarshal([]byte(str), &js) == nil
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment