Class MiniJsonExtensions
Extension class for MiniJson to access values in JSON format.
Inherited Members
Namespace: UnityEngine .Purchasing.MiniJSON
Assembly: solution.dll
Syntax
public static class MiniJsonExtensions
Methods
ArrayListFromJson(string)
Convert string JSON into List of Objects.
Declaration
public static List<object> ArrayListFromJson(this string json)
Parameters
Type | Name | Description |
---|---|---|
string | json | String JSON to convert. |
Returns
GetBool(Dictionary<string, object>, string)
Get the bool in the JSON dictionary.
Declaration
public static bool GetBool(this Dictionary<string, object> dic, string key)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<string, object> | dic | The JSON in dictionary representations. |
string | key | The Key to get the bool from in the JSON dictionary. |
Returns
Type | Description |
---|---|
bool | The bool from the JSON dictionary or false if the key was not found in the JSON dictionary |
GetEnum<T>(Dictionary<string, object>, string)
Get the casted enum in the JSON dictionary.
Declaration
public static T GetEnum<T>(this Dictionary<string, object> dic, string key)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<string, object> | dic | The JSON in dictionary representations. |
string | key | The Key to get the casted enum from in the JSON dictionary. |
Returns
Type | Description |
---|---|
T | The casted enum or will return T if the key was not found in the JSON dictionary. |
Type Parameters
Name | Description |
---|---|
T | The class to cast the enum. |
GetHash(Dictionary<string, object>, string)
Get the HashDictionary of a key in JSON dictionary.
Declaration
public static Dictionary<string, object> GetHash(this Dictionary<string, object> dic, string key)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<string, object> | dic | The JSON in dictionary representations. |
string | key | The Key to get the HashDictionary from in the JSON dictionary. |
Returns
Type | Description |
---|---|
Dictionary<string, object> | The HashDictionary found in the JSON |
GetLong(Dictionary<string, object>, string)
Get the long in the JSON dictionary.
Declaration
public static long GetLong(this Dictionary<string, object> dic, string key)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<string, object> | dic | The JSON in dictionary representations. |
string | key | The Key to get the long from in the JSON dictionary. |
Returns
Type | Description |
---|---|
long | The long from the JSON dictionary or 0 if the key was not found in the JSON dictionary |
GetString(Dictionary<string, object>, string, string)
Get the string in the JSON dictionary.
Declaration
public static string GetString(this Dictionary<string, object> dic, string key, string defaultValue = "")
Parameters
Type | Name | Description |
---|---|---|
Dictionary<string, object> | dic | The JSON in dictionary representations. |
string | key | The Key to get the string from in the JSON dictionary. |
string | defaultValue | The default value to send back if the JSON dictionary doesn't contains the key. |
Returns
Type | Description |
---|---|
string | The string from the JSON dictionary or the default value if there is none |
GetStringList(Dictionary<string, object>, string)
Get the list of strings in the JSON dictionary.
Declaration
public static List<string> GetStringList(this Dictionary<string, object> dic, string key)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<string, object> | dic | The JSON in dictionary representations. |
string | key | The Key to get the list of strings from in the JSON dictionary. |
Returns
Type | Description |
---|---|
List<string> | The list of strings from the JSON dictionary or an empty list of strings if the key was not found in the JSON dictionary |
Get<T>(Dictionary<string, object>, string)
Get the casted object in the JSON dictionary.
Declaration
public static T Get<T>(this Dictionary<string, object> dic, string key)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<string, object> | dic | The JSON in dictionary representations. |
string | key | The Key to get the casted object from in the JSON dictionary. |
Returns
Type | Description |
---|---|
T | The casted object or will return T if the key was not found in the JSON dictionary. |
Type Parameters
Name | Description |
---|---|
T | The class to cast the object. |
HashtableFromJson(string)
Convert string JSON into Dictionary.
Declaration
public static Dictionary<string, object> HashtableFromJson(this string json)
Parameters
Type | Name | Description |
---|---|---|
string | json | String JSON to convert. |
Returns
Type | Description |
---|---|
Dictionary<string, object> | Dictionary converted from string json. |
toJson(Dictionary<string, object>)
Convert a Dictionary to JSON.
Declaration
public static string toJson(this Dictionary<string, object> obj)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<string, object> | obj | The dictionary to convert to JSON. |
Returns
Type | Description |
---|---|
string | The converted dictionary in JSON string format. |
toJson(Dictionary<string, string>)
Convert a Dictionary to JSON.
Declaration
public static string toJson(this Dictionary<string, string> obj)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<string, string> | obj | The dictionary to convert to JSON. |
Returns
Type | Description |
---|---|
string | The converted dictionary in JSON string format. |
toJson(string[])
Convert a string array to JSON.
Declaration
public static string toJson(this string[] array)
Parameters
Type | Name | Description |
---|---|---|
string[] | array | The string array to convert to JSON. |
Returns
Type | Description |
---|---|
string | The converted dictionary in JSON string format. |