Class JsonHelper
This is a static class that performs various JSON related functions such as serialization and deserialization.
Inherited Members
Namespace: Ng911Lib.Utilities
Assembly: Ng911Lib.dll
Syntax
public static class JsonHelper
Methods
| Edit this page View SourceDeserializeFromString<T>(string)
Deserializes a JSON string into an object.
Declaration
public static T DeserializeFromString<T>(string str)
Parameters
Type | Name | Description |
---|---|---|
string | str | Input string to deserialize |
Returns
Type | Description |
---|---|
T | Returns an object of the specified type if successful or null if an error occurred. |
Type Parameters
Name | Description |
---|---|
T | Specifies the type of the object to deserialize the JSON string into. |
DeserializeFromString<T>(string, out Exception)
Deserializes a JSON string into an object.
Declaration
public static T DeserializeFromString<T>(string str, out Exception Excpt)
Parameters
Type | Name | Description |
---|---|---|
string | str | Input JSON string |
Exception | Excpt | Output. Set to the exception object that was caught. This will be non-null if the return value is null. |
Returns
Type | Description |
---|---|
T | Returns an object of the specified type if successful or null if an error occurred. |
Type Parameters
Name | Description |
---|---|
T | Specifies the type of the object to deserialize the JSON string into. |
Remarks
Use this version of the method of you need to log and/or troubleshoot JSON issues.
SerializeToString(object)
Serializes an object into an indented JSON string.
Declaration
public static string SerializeToString(object Obj)
Parameters
Type | Name | Description |
---|---|---|
object | Obj | Input object to serialize |
Returns
Type | Description |
---|---|
string | Returns an indented JSON string if no errors occurred. Returns null if an error occurred. |