If I have:
void MyMethod(Object obj) { ... }
How can I cast obj to what its actual type is?
This method might not be the most efficient but is simple and does the job.
It performs two operations: firstly it calls .ToString() which is basiclly a serialization, and then the deserialization using Newtonsoft nuget (which you must install).
public T Format(Object obj) =>
JsonConvert.DeserializeObject(obj.ToString());