Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[RELEASED] Easy JSON Hashtable

Discussion in 'Assets and Asset Store' started by blueddarker, Jan 17, 2015.

  1. blueddarker

    blueddarker

    Joined:
    Jan 17, 2015
    Posts:
    12
    Hi,

    Easy JSON Hashtable is available Link to Asset Store

    Overview
    This package is very easy and can be easily converted JSON.
    JSON string can be easily converted into Hashtable.
    Hashtable that also can be easily converted into a JSON string.

    Features
    • JSON -> Hashtable
    • JSON -> ArrayList
    • Hashtable -> JSON
    • ArrayList -> JSON
    Functions
    * Decode
    easy.JSON.JsonDecode(string json)

    – json : Input Json string.
    - output : Unity object.(Hashtable or ArrayList)​

    * Encode
    easy.JSON.JsonEncode(object json)

    – json : Unity object.(Hashtable or ArrayList)
    - output : Json string.
    Samples
    Decode Json
    * Json string -> Hashtable

    string json = “{\”name\”:\”John\”}”;
    Hashtable table = (Hashtable)easy.JSON.JsonDecode(json);
    Debug.Log(“[DECODE]Hashtable -> Name : ” + table[“name”]);

    * Json string -> Arraylist
    string json = “[100, 500, 800]”;
    ArrayList list = (ArrayList)easy.JSON.JsonDecode(json);
    string output = “”;
    foreach(object data in list)
    {
    output += data.ToString() + ” “;
    }

    Debug.Log(“[DECODE]ArrayList : ” + output);

    * Json string -> Objects
    string json = “{\”data\”:{\”birth_year\”:\”1990\”, \”gender\”:\”man\”, \”friends\”:[\”John\”, \”Daniel\”], \”age\”:15}, \”name\”:\”Josh\”}”;
    Hashtable table = (Hashtable)easy.JSON.JsonDecode(json);
    Hashtable data = (Hashtable)table[“data”];
    string output = “”;
    foreach(DictionaryEntry pair in data)
    {
    output += string.Format(“{0}={1} “, pair.Key, pair.Value);
    }
    Debug.Log(“[DECODE]Objects : ” + output);


    Encode Json
    * Hashtable -> Json string

    Hashtable table = new Hashtable();
    table.Add(“name”, “John”);
    string json = easy.JSON.JsonEncode(table);
    Debug.Log(“[ENCODE]Hashtable : ” + json);

    * Arraylist -> Json string
    ArrayList list = new ArrayList();
    list.Add(100);
    list.Add(500);
    list.Add(800);
    string json = easy.JSON.JsonEncode(list);
    Debug.Log(“[ENCODE]ArrayList : ” + json);

    * Objects -> Json string
    Hashtable table = new Hashtable();
    table.Add(“name”, “Josh”);
    {
    Hashtable data = new Hashtable();
    data.Add(“age”, 15);
    data.Add(“gender”, “man”);
    data.Add(“birth_year”, “1990”);
    {
    ArrayList list = new ArrayList();
    list.Add(“John”);
    list.Add(“Daniel”);
    data.Add(“friends”, list);
    }
    table.Add(“data”, data);
    }
    string json = easy.JSON.JsonEncode(table);
    Debug.Log(“[ENCODE]Object : ” + json);​
     

    Attached Files:

    Last edited: Jan 17, 2015
  2. gjf

    gjf

    Joined:
    Feb 8, 2012
    Posts:
    53
    "Easy Crypto - Encryption is available Link to Asset Store" - you might want to fix that...
     
  3. blueddarker

    blueddarker

    Joined:
    Jan 17, 2015
    Posts:
    12
    Thanks... fix title ^^
     
    gjf likes this.