JSONObject.HasField C# (CSharp) Method

HasField() public method

public HasField ( string name ) : bool
name string
return bool
	public bool HasField(string name)
	{
		if (type == Type.OBJECT)
			for (int i = 0; i < keys.Count; i++)
				if (keys[i] == name)
					return true;
		return false;
	}
	public void Clear()

Usage Example

Example #1
0
    public static JSONAble UnSerialize(JSONObject jsonObject)
    {
        JSONAble r = null;

        if (jsonObject.HasField("_class") && jsonObject.HasField("_data"))
        {
            string c = jsonObject.GetField("_class").str;
            Type t = Type.GetType(c);
            if (t.IsSubclassOf(typeof(JSONAble)))
            {
                if (t.IsSubclassOf(typeof(ScriptableObject)))
                {
                    r = ScriptableObject.CreateInstance(t) as JSONAble;
                    r.fromJSONObject(jsonObject.GetField("_data"));
                }
            }
        }
        else if (jsonObject.IsArray)
        {
            r = ScriptableObject.CreateInstance<IsoUnityCollectionType>();
            r.fromJSONObject(jsonObject);
        }
        else if (jsonObject.IsString || jsonObject.IsNumber || jsonObject.IsBool)
        {
            r = ScriptableObject.CreateInstance<IsoUnityBasicType>();
            r.fromJSONObject(jsonObject);
        }

        return r;
    }
All Usage Examples Of JSONObject::HasField