JsonHelperSerializeT(T, String, JsonSerializerOptions) Method

Writes a Json file of the provided object type.

Definition

Namespace: Common.Core.Classes
Assembly: Common.Core (in Common.Core.dll) Version: 2.1.5
C#
public static bool Serialize<T>(
	T obj,
	string fileName,
	JsonSerializerOptions? options = null
)
where T : class

Parameters

obj  T
Object to save.
fileName  String
Json file name.
options  JsonSerializerOptions  (Optional)
Optional Json serializer options.

Type Parameters

T
Generic class or interface.

Return Value

Boolean
if the object was saved.

Exceptions

ArgumentExceptionThrown when one of the arguments provided to a method is not valid.
IOExceptionThrown when an I/O error occurs.
NotSupportedExceptionThrown when an invoked method is not supported, or when there is an attempt to read, seek, or write to a stream that does not support the invoked functionality.
SecurityExceptionThrown when a security error is detected.
UnauthorizedAccessExceptionThrown when the operating system denies access because of an I/O error or a specific type of security error.

See Also