Show / Hide Table of Contents

    Class CollectionConverter<T, TList, TDictionary>

    Converts a complex JSON object into .NET primitives. For arrays, the configured list collection type TList is used. Objects are deserialized into the configured dictionary type TDictionary, storing each object property as a KeyValuePair<TKey, TValue>.
    Inheritance
    Newtonsoft.Json.JsonConverter
    CollectionConverter<T, TList, TDictionary>
    CollectionConverter<T>
    Namespace: XploRe.Json
    Assembly: XploRe.Json.dll
    Syntax
    public class CollectionConverter<T, TList, TDictionary> : JsonConverter where TList : ICollection<T>, new ()where TDictionary : IDictionary<string, T>, new ()
    Type Parameters
    Name Description
    T Type used for items. If a deserialised value cannot be converted into T, an exception is thrown. Can be used to enforce a certain data type, e.g. string, for all primitives. To retain the JSON type of a primitive, use Object.
    TList List type that implements System.Collections.Generic.ICollection<> that is used for arrays. Must provide a parameterless constructor.
    TDictionary Dictionary type that implements System.Collections.Generic.IDictionary<, > that is used for objects whose properties are stored as KeyValuePair<TKey, TValue>s. Keys are always Strings.

    Constructors

    Name Description
    CollectionConverter()

    Properties

    Name Description
    CanRead
    CanWrite
    DictionaryType The Type used for dictionaries.
    ItemType The Type used for collection items.
    ListType The Type used for lists.

    Methods

    Name Description
    CanConvert(Type)
    ReadJson(JsonReader, Type, Object, JsonSerializer)
    ReadValue(JsonReader, JsonSerializer) Called recursively to read and deserialise the current value.
    WriteJson(JsonWriter, Object, JsonSerializer)
    Back to top Copyright © 2017-2018, xplo.re IT Services, Michael Maier. All rights reserved.