Show / Hide Table of Contents

Class LdJsonSerialization

Helper methods for JSON serialization of SDK classes.

Inheritance
System.Object
LdJsonSerialization
Namespace: LaunchDarkly.Sdk.Json
Assembly: LaunchDarkly.CommonSdk.dll
Syntax
public static class LdJsonSerialization : Object
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
System.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
System.Text.Json.JsonException

if the JSON encoding was invalid

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
System.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.

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
System.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.

In This Article
Back to top Generated by DocFX