Class MiniJsonExtensions
Extension class for MiniJson to access values in JSON format.
Inherited Members
Namespace: UnityEngine.Purchasing.MiniJSON
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
Type | Description |
---|---|
List<Object> | List of Objects converted from string json. |
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. |
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 |
---|---|
Boolean | 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 |
---|---|
Int64 | 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 |
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. |