Table of Contents

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 bool

Whether to write the json keys as DICOM keywords instead of tags. This makes the json non-compliant to DICOM JSON.

autoValidate bool

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!

public bool WriteKeyword { get; set; }

Property Value

bool

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

bool

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 string

The 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 Utf8JsonReader

The Utf8JsonReader to read from.

typeToConvert Type

Type of the object.

options JsonSerializerOptions

Options 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 Utf8JsonWriter

The Utf8JsonWriter to write to.

value DicomDataset

The value.

options JsonSerializerOptions