Class JsonDictionaryUtility
Namespace: i5.Toolkit.Core.Utilities
Assembly: cs.temp.dll.dll
Syntax
public static class JsonDictionaryUtility
Methods
FromJson<K, V>(String)
Deserializes a JSON string to a dictionary
Declaration
public static Dictionary<K, V> FromJson<K, V>(string json)
Parameters
| Type | Name | Description |
|---|---|---|
| String | json | The json string which should be parsed |
Returns
| Type | Description |
|---|---|
| Dictionary<K, V> | Returns the deserialized dictionary |
Type Parameters
| Name | Description |
|---|---|
| K | The type of the dictionary's keys |
| V | The type of the dictionary's values |
ToJson<K, V>(Dictionary<K, V>, Boolean)
Serializes a dictionary to a JSON string
Declaration
public static string ToJson<K, V>(Dictionary<K, V> dict, bool prettyPrint = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Dictionary<K, V> | dict | The dictionary which should be serialized |
| Boolean | prettyPrint | If true, the JSON string will be formatted to be better human-readable |
Returns
| Type | Description |
|---|---|
| String | Returns the serialized JSON string |
Type Parameters
| Name | Description |
|---|---|
| K | The type of the dictionary's keys |
| V | The type of the dictionary's values |