Example #1
0
    /// <summary>
    /// Parses the string json into a value
    /// </summary>
    /// <param name="json">A JSON string.</param>
    /// <returns>An ArrayList, a Hashtable, a double, a string, null, true, or false</returns>
    public static object jsonDecode(string json)
    {
        // save the string for debug information
        NGUIJson.lastDecode = json;

        if (json != null)
        {
            char[] charArray = json.ToCharArray();
            int    index     = 0;
            bool   success   = true;
            object value     = NGUIJson.parseValue(charArray, ref index, ref success);

            if (success)
            {
                NGUIJson.lastErrorIndex = -1;
            }
            else
            {
                NGUIJson.lastErrorIndex = index;
            }

            return(value);
        }
        else
        {
            return(null);
        }
    }