Class DicomJsonConverter
Converts a DicomDataset object to and from JSON using the System.Text.Json library
Inheritance
Inherited Members
Namespace: FellowOakDicom.Serialization
Assembly: fo-dicom.core.dll
Syntax
public class DicomJsonConverter : JsonConverter<DicomDataset>
Constructors
DicomJsonConverter(Boolean, Boolean, NumberSerializationMode)
Initialize the JsonDicomConverter.
Declaration
public DicomJsonConverter(bool writeTagsAsKeywords = false, bool autoValidate = true, NumberSerializationMode numberSerializationMode = NumberSerializationMode.AsNumber)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | writeTagsAsKeywords | Whether to write the json keys as DICOM keywords instead of tags. This makes the json non-compliant to DICOM JSON. |
System.Boolean | autoValidate | Whether the content of DicomItems shall be validated when deserializing. |
NumberSerializationMode | numberSerializationMode | Defines 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!
Declaration
public bool WriteKeyword { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
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!
Declaration
public bool WriteName { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
CanConvert(Type)
Determines whether this instance can convert the specified object type.
Declaration
public override bool CanConvert(Type typeToConvert)
Parameters
Type | Name | Description |
---|---|---|
System.Type | typeToConvert |
Returns
Type | Description |
---|---|
System.Boolean |
|
Overrides
CreateBulkDataUriByteBuffer(String)
Create an instance of a IBulkDataUriByteBuffer. Override this method to use a different IBulkDataUriByteBuffer implementation in applications.
Declaration
protected virtual IBulkDataUriByteBuffer CreateBulkDataUriByteBuffer(string bulkDataUri)
Parameters
Type | Name | Description |
---|---|---|
System.String | bulkDataUri | The URI of a bulk data element as defined in Table A.1.5-2 in PS3.19. |
Returns
Type | Description |
---|---|
IBulkDataUriByteBuffer | An instance of a Bulk URI Byte buffer. |
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Reads the JSON representation of the object.
Declaration
public override DicomDataset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
Type | Name | Description |
---|---|---|
System.Text.Json.Utf8JsonReader | reader | The System.Text.Json.Utf8JsonReader to read from. |
System.Type | typeToConvert | Type of the object. |
System.Text.Json.JsonSerializerOptions | options | Options to apply while reading. |
Returns
Type | Description |
---|---|
DicomDataset | The object value. |
Overrides
Write(Utf8JsonWriter, DicomDataset, JsonSerializerOptions)
Writes the JSON representation of the object.
Declaration
public override void Write(Utf8JsonWriter writer, DicomDataset value, JsonSerializerOptions options)
Parameters
Type | Name | Description |
---|---|---|
System.Text.Json.Utf8JsonWriter | writer | The System.Text.Json.Utf8JsonWriter to write to. |
DicomDataset | value | The value. |
System.Text.Json.JsonSerializerOptions | options |