Class DicomJsonConverter
- Namespace
- FellowOakDicom.Serialization
- Assembly
- fo-dicom.core.dll
Converts a DicomDataset object to and from JSON using the System.Text.Json library
public class DicomJsonConverter : JsonConverter<DicomDataset>
- Inheritance
-
DicomJsonConverter
- Inherited Members
- Extension Methods
Constructors
DicomJsonConverter(bool, bool, NumberSerializationMode)
Initialize the JsonDicomConverter.
public DicomJsonConverter(bool writeTagsAsKeywords = false, bool autoValidate = true, NumberSerializationMode numberSerializationMode = NumberSerializationMode.AsNumber)
Parameters
writeTagsAsKeywords
boolWhether to write the json keys as DICOM keywords instead of tags. This makes the json non-compliant to DICOM JSON.
autoValidate
boolWhether the content of DicomItems shall be validated when deserializing.
numberSerializationMode
NumberSerializationModeDefines how numbers should be serialized. Default 'AsNumber', will throw errors when a number is not parsable.
Properties
WriteKeyword
With his option enabled, Dicom tag keyword will be written as a distinct Json attribute. Note! This is non-standard and may break parsers!
public bool WriteKeyword { get; set; }
Property Value
WriteName
With his option enabled, Dicom tag name will be written as a distinct Json attribute. Note! This is non-standard and may break parsers!
public bool WriteName { get; set; }
Property Value
Methods
CanConvert(Type)
Determines whether this instance can convert the specified object type.
public override bool CanConvert(Type typeToConvert)
Parameters
typeToConvert
Type
Returns
- bool
true
if this instance can convert the specified object type; otherwise,false
.
CreateBulkDataUriByteBuffer(string)
Create an instance of a IBulkDataUriByteBuffer. Override this method to use a different IBulkDataUriByteBuffer implementation in applications.
protected virtual IBulkDataUriByteBuffer CreateBulkDataUriByteBuffer(string bulkDataUri)
Parameters
bulkDataUri
stringThe URI of a bulk data element as defined in Table A.1.5-2 in PS3.19.
Returns
- IBulkDataUriByteBuffer
An instance of a Bulk URI Byte buffer.
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Reads the JSON representation of the object.
public override DicomDataset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
reader
Utf8JsonReaderThe Utf8JsonReader to read from.
typeToConvert
TypeType of the object.
options
JsonSerializerOptionsOptions to apply while reading.
Returns
- DicomDataset
The object value.
Write(Utf8JsonWriter, DicomDataset, JsonSerializerOptions)
Writes the JSON representation of the object.
public override void Write(Utf8JsonWriter writer, DicomDataset value, JsonSerializerOptions options)
Parameters
writer
Utf8JsonWriterThe Utf8JsonWriter to write to.
value
DicomDatasetThe value.
options
JsonSerializerOptions