public Card(JSONClass json)
{
if (json == null) {
throw new ArgumentNullException("json");
}
JsonString = json.ToString();
if (json["id"] == null || json["type"] == null || json["viewed"] == null || json["created"] == null || json["updated"] == null) {
throw new ArgumentException("Missing required field(s).");
}
ID = json["id"];
Type = json["type"];
Viewed = json["viewed"].AsBool;
Created = json["created"].AsInt;
Updated = json["updated"].AsInt;
if (json["extras"] != null) {
Extras = JsonUtils.JSONClassToDictionary(json["extras"].AsObject);
}
Categories = new HashSet<CardCategory>();
if (json["categories"] == null) {
Categories.Add(CardCategory.NO_CATEGORY);
} else {
JSONArray jsonArray = (JSONArray)JSON.Parse(json["categories"].ToString());
if (jsonArray == null || jsonArray.Count == 0) {
Categories.Add(CardCategory.NO_CATEGORY);
} else {
for (int i = 0; i < jsonArray.Count; i++) {
CardCategory category = (CardCategory)EnumUtils.TryParse(typeof(CardCategory), jsonArray[i], true, null);
if (category != null) {
Categories.Add(category);
}
}
}
}
}