Show / Hide Table of Contents

Class JsonHelpers

Inheritance
System.Object
JsonHelpers
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: WSCT.Helpers.Json
Assembly: WSCT.Helpers.dll
Syntax
public static class JsonHelpers

Methods

| Improve this Doc View Source

CreateFromJsonFile<T>(String)

Reads (deserializes) an instance of type from a JSON file.

Declaration
public static T CreateFromJsonFile<T>(this string fileName)
Parameters
Type Name Description
System.String fileName

JSON source path and filename.

Returns
Type Description
T

A new instance of read from .

Type Parameters
Name Description
T

Target instance type.

| Improve this Doc View Source

CreateFromJsonPersistentStream<T>(Stream)

Reads (deserializes) an instance of type from a JSON stream. Warning: the stream is not closed and must be disposed by the caller.

Declaration
public static T CreateFromJsonPersistentStream<T>(this Stream stream)
Parameters
Type Name Description
System.IO.Stream stream

JSON source stream.

Returns
Type Description
T

A new instance of read from .

Type Parameters
Name Description
T

Target instance type.

| Improve this Doc View Source

CreateFromJsonStream<T>(Stream)

Reads (deserializes) an instance of type from a JSON stream. The stream is safely disposed by the method.

Declaration
public static T CreateFromJsonStream<T>(this Stream stream)
Parameters
Type Name Description
System.IO.Stream stream

JSON source stream.

Returns
Type Description
T

A new instance of read from .

Type Parameters
Name Description
T

Target instance type.

| Improve this Doc View Source

CreateFromJsonString<T>(String)

Reads (deserializes) an instance of type from a JSON string.

Declaration
public static T CreateFromJsonString<T>(this string json)
Parameters
Type Name Description
System.String json

JSON source string.

Returns
Type Description
T

A new instance of read from .

Type Parameters
Name Description
T

Target instance type.

| Improve this Doc View Source

WriteToJsonFile(Object, String)

Writes (serializes) an instance to a JSON file.

Declaration
public static void WriteToJsonFile(this object instance, string fileName)
Parameters
Type Name Description
System.Object instance
System.String fileName
| Improve this Doc View Source

WriteToJsonFile(Object, String, Boolean)

Writes (serializes) an instance to a JSON file.

Declaration
public static void WriteToJsonFile(this object instance, string fileName, bool indented)
Parameters
Type Name Description
System.Object instance
System.String fileName
System.Boolean indented
| Improve this Doc View Source

WriteToJsonString(Object)

Writes (serializes) an instance to a json string.

Declaration
public static string WriteToJsonString(this object instance)
Parameters
Type Name Description
System.Object instance
Returns
Type Description
System.String
| Improve this Doc View Source

WriteToJsonString(Object, Boolean)

Writes (serializes) an instance to a json string.

Declaration
public static string WriteToJsonString(this object instance, bool indented)
Parameters
Type Name Description
System.Object instance
System.Boolean indented
Returns
Type Description
System.String
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX