Пример #1
0
        internal static JSONObject ParseInternal(string json)
        {
            JSONObject json_object = null;

            int    n;
            double d;
            bool   b;

            if (json.StartsWith('['))
            {
                if (json.StartsWith("[{"))
                {
                    JSONTableArray table_array = new JSONTableArray(json.Substring(1, json.Length - 2));
                    json_object = new JSONObject(table_array);
                }
                else
                {
                    JSONObjectArray object_array = new JSONObjectArray(json.Substring(1, json.Length - 2));
                    json_object = new JSONObject(object_array);
                }
            }
            else if (json.StartsWith('{'))
            {
                JSONTable table = new JSONTable(json.Substring(1, json.Length - 2));
                json_object = new JSONObject(table);
            }
            else if (json.StartsWith('"'))
            {
                json_object = new JSONObject(json.Substring(1, json.Length - 2));
            }
            else if (int.TryParse(json, out n))
            {
                json_object = new JSONObject(n);
            }
            else if (double.TryParse(json, out d))
            {
                json_object = new JSONObject(d);
            }
            else if (bool.TryParse(json, out b))
            {
                json_object = new JSONObject(b);
            }
            else if (json == "null")
            {
                json_object = new JSONObject();
            }
            else
            {
                throw new Exception("could not parse " + json + " : " + json.Length);
            }

            return(json_object);
        }
Пример #2
0
 internal JSONObject(JSONTableArray value)
 {
     table_array_value = value;
     is_table_array    = true;
 }