Class ExceptionConverter
- Namespace
- Codebelt.Extensions.Newtonsoft.Json.Converters
- Assembly
- Codebelt.Extensions.Newtonsoft.Json.dll
Converts an Exception to or from JSON.
public class ExceptionConverter : JsonConverter
- Inheritance
-
JsonConverterExceptionConverter
- Inherited Members
-
JsonConverter.CanReadJsonConverter.CanWrite
Constructors
ExceptionConverter(bool, bool)
Initializes a new instance of the ExceptionConverter class.
public ExceptionConverter(bool includeStackTrace = false, bool includeData = false)
Parameters
includeStackTraceboolA value that indicates if the stack of an exception is included in the converted result.
includeDataboolA value that indicates if the data of an exception is included in the converted result.
Properties
IncludeData
Gets a value indicating whether the data of an exception is included in the converted result.
public bool IncludeData { get; }
Property Value
- bool
trueif the data of an exception is included in the converted result; otherwise,false.
IncludeStackTrace
Gets a value indicating whether the stack of an exception is included in the converted result.
public bool IncludeStackTrace { get; }
Property Value
- bool
trueif the stack of an exception is included in the converted result; otherwise,false.
Methods
CanConvert(Type)
Determines whether this instance can convert the specified object type.
public override bool CanConvert(Type objectType)
Parameters
objectTypeTypeType of the object.
Returns
- bool
trueif this instance can convert the specified object type; otherwise,false.
ReadJson(JsonReader, Type, object, JsonSerializer)
Reads the JSON representation of the object.
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
Parameters
readerJsonReaderThe Newtonsoft.Json.JsonReader to read from.
objectTypeTypeType of the object.
existingValueobjectThe existing value of object being read.
serializerJsonSerializerThe calling serializer.
Returns
- object
The object value.
WriteJson(JsonWriter, object, JsonSerializer)
Writes the JSON representation of the object.
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
Parameters
writerJsonWriterThe Newtonsoft.Json.JsonWriter to write to.
valueobjectThe value.
serializerJsonSerializerThe calling serializer.