Table of Contents

Class JsonSerializer

Namespace
NetCoreForce.Client
Assembly
NetCoreForce.Client.dll
public static class JsonSerializer
Inheritance
JsonSerializer
Inherited Members

Methods

Deserialize<T>(string)

Deserializes raw JSON into given type

public static T Deserialize<T>(string json)

Parameters

json string

JSON object string

Returns

T

Type Parameters

T

SerializeComplete(object, bool, List<string>, bool)

Serializes an object into JSON including all non-null properties.

Not to be used for create and update calls

public static string SerializeComplete(object inputObject, bool indented, List<string> fieldsToNull = null, bool ignoreNulls = true)

Parameters

inputObject object

Object to serialize

indented bool

use indented formatting, usually for readability

fieldsToNull List<string>

A list of properties that should be set to null, but inclusing the null values in the serialized output

ignoreNulls bool

Use with caution. By default null values are not serialized, this will serialize all explicitly nulled or missing properties as null

Returns

string

JSON string

SerializeForCreate(object, List<string>, bool)

Serializes an object into JSON for SObject creation, using the CreateableContractResolver

public static string SerializeForCreate(object inputObject, List<string> fieldsToNull = null, bool ignoreNulls = true)

Parameters

inputObject object

Object to serialize

fieldsToNull List<string>

A list of properties that should be set to null, but inclusing the null values in the serialized output

ignoreNulls bool

Use with caution. By default null values are not serialized, this will serialize all explicitly nulled or missing properties as null

Returns

string

JSON string, unformatted

SerializeForUpdate(object, List<string>, bool)

Serializes an object into JSON for SObject updates, using the UpdateableContractResolver

public static string SerializeForUpdate(object inputObject, List<string> fieldsToNull = null, bool ignoreNulls = true)

Parameters

inputObject object

Object to serialize

fieldsToNull List<string>

A list of properties that should be set to null, but inclusing the null values in the serialized output

ignoreNulls bool

Use with caution. By default null values are not serialized, this will serialize all explicitly nulled or missing properties as null

Returns

string

SerializeForUpdateWithObjectId(object, List<string>, bool)

Serializes an object into JSON for SObject updates, using the UpdateableContractResolver. Includes the SObject ID for calls that require it

public static string SerializeForUpdateWithObjectId(object inputObject, List<string> fieldsToNull = null, bool ignoreNulls = true)

Parameters

inputObject object

Object to serialize

fieldsToNull List<string>

A list of properties that should be set to null, but inclusing the null values in the serialized output

ignoreNulls bool

Use with caution. By default null values are not serialized, this will serialize all explicitly nulled or missing properties as null

Returns

string

JSON string, unformatted