Hydrogen Framework
1.3.1
|
This class encodes and decodes JSON strings. Spec. details, see http://www.json.org/ More...
Static Public Member Functions | |
static JSONObject | Deserialize (string json) |
Parses the string json into a value More... | |
static string | Serialize (JSONObject jsonObject) |
Converts a IDictionary / IList object or a simple type (string, int, etc.) into a JSON string More... | |
This class encodes and decodes JSON strings. Spec. details, see http://www.json.org/
JSON uses Arrays and Objects. These correspond here to the datatypes IList and IDictionary. All numbers are parsed to doubles.
|
static |
Parses the string json into a value
json | A JSON string. |
var dict = Json.Deserialize(jsonString) as Dictionary<string,object>;
Debug.Log("deserialized: " + dict.GetType()); Debug.Log("dict['array'][0]: " + ((List<object>) dict["array"])[0]); Debug.Log("dict['string']: " + (string) dict["string"]); Debug.Log("dict['float']: " + (double) dict["float"]); // floats come out as doubles Debug.Log("dict['int']: " + (long) dict["int"]); // ints come out as longs Debug.Log("dict['unicode']: " + (string) dict["unicode"]);
|
static |
Converts a IDictionary / IList object or a simple type (string, int, etc.) into a JSON string
jsonObject | A Dictionary<string, object> / List<object> |
string jsonString = Hydrogen.Serialization.JSON.Serialize(object);