Class JsonHelpers
Inheritance
Inherited Members
Namespace: WSCT.Helpers.Json
Assembly: WSCT.Helpers.dll
Syntax
public static class JsonHelpers
Methods
| Improve this Doc View SourceCreateFromJsonFile<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. |
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. |
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. |
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. |
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 |
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 |
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 |
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 |