LaunchDarkly Dotnet Client SDK
Search Results for

    Show / Hide Table of Contents

    Class LdJsonSerialization

    Helper methods for JSON serialization of SDK classes.

    Inheritance
    object
    LdJsonSerialization
    Inherited Members
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: LaunchDarkly.Sdk.Json
    Assembly: LaunchDarkly.CommonSdk.dll
    Syntax
    public static class LdJsonSerialization
    Remarks

    These methods can be used with any SDK type that has the IJsonSerializable marker interface.

    Methods

    DeserializeObject<T>(string)

    Parses an object from its JSON representation.

    Declaration
    public static T DeserializeObject<T>(string json) where T : IJsonSerializable
    Parameters
    Type Name Description
    string json

    the object's JSON encoding as a string

    Returns
    Type Description
    T

    the deserialized instance

    Type Parameters
    Name Description
    T

    type of the object being deserialized

    Remarks

    This is exactly equivalent to the System.Text.Json method JsonSerializer.Deserialize, except that it only accepts LaunchDarkly types that have the IJsonSerializable marker interface. It is retained for backward compatibility.

    Exceptions
    Type Condition
    JsonException

    if the JSON encoding was invalid

    SerializeObjectToUtf8Bytes<T>(T)

    Converts an object to its JSON representation as a UTF-8 byte array.

    Declaration
    public static byte[] SerializeObjectToUtf8Bytes<T>(T instance) where T : IJsonSerializable
    Parameters
    Type Name Description
    T instance

    the instance to serialize

    Returns
    Type Description
    byte[]

    the object's JSON encoding as a byte array

    Type Parameters
    Name Description
    T

    type of the object being serialized

    Remarks

    This is exactly equivalent to the System.Text.Json method JsonSerializer.SerializeToUtf8Bytes, except that it only accepts LaunchDarkly types that have the IJsonSerializable marker interface. It is retained for backward compatibility.

    SerializeObject<T>(T)

    Converts an object to its JSON representation.

    Declaration
    public static string SerializeObject<T>(T instance) where T : IJsonSerializable
    Parameters
    Type Name Description
    T instance

    the instance to serialize

    Returns
    Type Description
    string

    the object's JSON encoding as a string

    Type Parameters
    Name Description
    T

    type of the object being serialized

    Remarks

    This is exactly equivalent to the System.Text.Json method JsonSerializer.Serialize, except that it only accepts LaunchDarkly types that have the IJsonSerializable marker interface. It is retained for backward compatibility.

    In this article
    Back to top Generated by DocFX