In my application I'm using newtonsoft to serialize and deserialize object, I want to know is there any built in API to determine that input string can deserialize to specific object or not?
public TObject Deserialize<TObject>(string serialized)
{
/// I want check the condition, and if is not serialized string just return default(TObject)
return JsonConvert.DeserializeObject<TObject>(serialized);
}
I don't want to use try catch
. Currently I implemented like that but looking to find a way to verify the string before start to deserialize object.
Already I saw this question Deserialize json in a "TryParse" way, but its not my answer cause I don't have any specific schema and JSON format can change dynamically.