I've a method that deserialize string into a type.
var data = JsonConvert.DeserializeObject<TestData>("invalid json");
If string is not valid, JsonReaderException occurring.
I want to return default value of TestData (null) when string is not valid instead of throw exception.
How can I do this without try/catch and JObject?
You can use
JsonSerializerSettingsto handle it the result of it will be NULL. The reference of JsonConvert.DeserializeObject and JsonSerializerSettings.Error