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; } }
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; } }
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)); }
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()); } }
public JSONObjectReuse(JSONObject.Type t) { JSONData = new JSONObject(t); }