示例#1
0
    public JSONObject(JSONObject.Type t)
    {
        type = t;
        switch (t)
        {
        case Type.ARRAY:
            list = new List <JSONObject>();
            break;

        case Type.OBJECT:
            list = new List <JSONObject>();
            keys = new List <string>();
            break;
        }
    }
示例#2
0
    public JSONObject(JSONObject.Type t)
    {
        type = t;
        switch (t)
        {
        case Type.ARRAY:
            list = new ArrayList();
            break;

        case Type.OBJECT:
            list = new ArrayList();
            keys = new ArrayList();
            break;
        }
    }
示例#3
0
 public static JSONObject asJSONObject(this JSONObject json, string name, JSONObject.Type expectedType = JSONObject.Type.OBJECT)
 {
     return(JSONConverter.Get(json, name, (JSONObject f) => f, () => new JSONObject(expectedType), expectedType));
 }
示例#4
0
 public static T Get <T>(JSONObject json, string name, Func <JSONObject, T> convert, Func <T> orDefault, JSONObject.Type expectedType = JSONObject.Type.NULL)
 {
     try
     {
         if (!json.HasField(name))
         {
             return(orDefault());
         }
         JSONObject field = json.GetField(name);
         if (expectedType != 0 && expectedType != field.type)
         {
             UnityEngine.Debug.LogError("Tried to get field '" + name + "' as " + expectedType + ", but it is incompatible (" + field.type + "). Returning default value.");
             return(orDefault());
         }
         return(convert(json.GetField(name)));
     }
     catch (Exception ex)
     {
         UnityEngine.Debug.LogError("Exception during converting '" + name + "' e:  " + ex.Message + ". Returning default value.");
         return(orDefault());
     }
 }
示例#5
0
 public JSONObjectReuse(JSONObject.Type t)
 {
     JSONData = new JSONObject(t);
 }