docs.unity3d.com
    Show / Hide Table of Contents

    Class MiniJsonExtensions

    Extension class for MiniJson to access values in JSON format.

    Inheritance
    Object
    MiniJsonExtensions
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    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.

    In This Article
    • Methods
      • ArrayListFromJson(String)
      • Get<T>(Dictionary<String, Object>, String)
      • GetBool(Dictionary<String, Object>, String)
      • GetEnum<T>(Dictionary<String, Object>, String)
      • GetHash(Dictionary<String, Object>, String)
      • GetLong(Dictionary<String, Object>, String)
      • GetString(Dictionary<String, Object>, String, String)
      • GetStringList(Dictionary<String, Object>, String)
      • HashtableFromJson(String)
      • toJson(Dictionary<String, Object>)
      • toJson(Dictionary<String, String>)
      • toJson(String[])
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023