[RELEASED] Easy JSON Hashtable

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);

“Easy Crypto - Encryption is available Link to Asset Store” - you might want to fix that…

Thanks… fix title ^^

1 Like