# Class DictionaryConverter

Namespace
  adas_core.Domain.Models.BsonConverters

Assembly
  adas-core.Domain.dll

Represents a JSON converter that handles serialization and deserialization of dictionary types.

    public class DictionaryConverter : JsonConverter

Inheritance
  object
  JsonConverter
  DictionaryConverter

Inherited Members
  JsonConverter.CanRead
  JsonConverter.CanWrite
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

Extension Methods
  NumberUtils.IsNumber(object)
  NumberUtils.ToDouble(object)
  ObjectUtils.ToStr(object?)

## Remarks

Inherits from Newtonsoft.Json.JsonConverter to provide custom conversion logic for dictionary-shaped data.

## Methods

### CanConvert(Type)

Determines whether the converter can handle the specified type. Returns `true` only when `objectType` is exactly Dictionary<TKey, TValue> with string keys and object values.

    public override bool CanConvert(Type objectType)

#### Parameters

`objectType` Type

  The type to evaluate for converter compatibility.

#### Returns

bool

  `true` if the type is Dictionary<TKey, TValue> of string and object; otherwise, `false`.

### ReadJson(JsonReader, Type, object?, JsonSerializer)

Deserializes a JSON object into a dictionary where each key maps to a strongly-typed value based on the property name. Handles "Steps" and "beacons" as lists of Step and LightBeacon respectively, "cameras" as a list of Camera, "relay" as a Relay instance, and stores any other properties as generic objects, using empty collections or default instances when the source value is null.

    public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)

#### Parameters

`reader` JsonReader

  The JSON reader used to read the input token.

`objectType` Type

  The type of the object being deserialized.

`existingValue` object

  The existing value of the object being read.

`serializer` JsonSerializer

  The JSON serializer used to deserialize nested values.

#### Returns

object

  A dictionary containing the JSON properties mapped to their deserialized values.

### WriteJson(JsonWriter, object?, JsonSerializer)

Serializes a dictionary of entries to JSON, writing each key-value pair as a JSON property using the provided serializer. Returns immediately when the value is null, leaving the writer untouched.

    public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)

#### Parameters

`writer` JsonWriter

  The JSON writer that receives the serialized output.

`value` object

  The dictionary to serialize; if null, nothing is written.

`serializer` JsonSerializer

  The serializer used to convert each dictionary value into a JSON token.