I’m trying to get data out of an object which I have not seen yet in swift. The type of the object is Any
.
func getMetaData(_ callback: @escaping (Error?) -> ()) {
guard let accessToken = self.credentials?.accessToken
else { return callback(CredentialsManagerError.noCredentials) }
Auth0
.users(token: accessToken)
.get(profile!.sub, fields: ["user_metadata"], include: true)
.start { (result) in
switch result {
case .success(let user):
print(user)
self.metadata = user
callback(nil)
case .failure(let error):
callback(error)
}
}
}
The object came to be as a dictionary [String:Any]
with any being (print(user)
):
["user_metadata": {
fname = abc;
lname = xyz;
}]
I got user_metadata
out and got this:
{
fname = abc;
lname = xyz;
}
This is eventually what I want to achieve:
UserMetaData(fname: "abc", lname: "xyz")
It’s not quite JSON and I have no clue what to do with it