static KeyType? tryFromJson(String? kty) { if (kty == null) return null; try { return fromJson(kty); } on StateError { return null; } }