Deserialize() публичный Метод

public Deserialize ( KnetikSimpleJSON.KnetikJSONNode json ) : void
json KnetikSimpleJSON.KnetikJSONNode
Результат void
Пример #1
0
        public override void Deserialize(KnetikJSONNode json)
        {
            base.Deserialize(json);

            Assets = new Dictionary<string, ItemAsset>();
            URLs = new Dictionary<string, string>();

            if (json ["assets"].AsArray != null)
            {
                foreach (KnetikJSONNode node in json["assets"].Children)
                {
                    string slug = node ["slug"].Value;
                    ItemAsset asset = new ItemAsset(Client);
                    asset.Deserialize(node ["asset"]);
                    Assets.Add(slug, asset);
                    URLs.Add(slug, asset.URL);
                }
            } else if (json ["urls"].AsArray != null)
            {
                foreach (KnetikJSONNode node in json["urls"].Children)
                {
                    URLs.Add(node["name"].Value, node["url"].Value);
                }
            }
        }
Пример #2
0
        public override void Deserialize(KnetikJSONNode json)
        {
            if(json == null || json.ToString() == "\"null\"")
            {
                return;
            }

            if (json ["id"] != null && json ["id"] != "null")
            {
                ID = json ["id"].AsInt;
            }

            UniqueKey = json ["unique_key"].Value;
            TypeHint = json ["type_hint"].Value;
            Name = json ["name"].Value;
            ShortDescription = json ["short_description"].Value;
            LongDescription = json ["long_description"].Value;

            Assets.Clear ();
            if (json ["assets"] != null) {
                foreach (KnetikJSONNode node in json["assets"].Children) {
                    ItemAsset asset = new ItemAsset (Client);
                    asset.Deserialize (node);
                    if (json ["behaviors"] != null) {
                        asset.setSlug(json ["behaviors"]);
                    }

                    Assets.Add (asset);
                }
            }

            Skus.Clear ();
            if (json ["skus"] != null) {
                foreach (KnetikJSONNode node in json["skus"].Children) {
                    CatalogSku sku = new CatalogSku (Client, this);
                    sku.Deserialize (node);
                    Skus.Add (sku);
                }
            }

            Behaviors.Clear();
            if (json ["behaviors"] != null) {
                foreach (KnetikJSONNode node in json["behaviors"].Children) {
                    Behavior behavior = Behavior.Parse (Client, node);
                    Behaviors.Add (behavior.TypeHint, behavior);
                }
            }

            if (json ["deleted_at"] != null && json ["deleted_at"] != "null")
            {
                DeletedAt = new DateTime (json ["deleted_at"].AsInt);
            }

            if (json ["date_created"] != null && json ["date_created"] != "null")
            {
                DateCreated = new DateTime (json ["date_created"].AsInt);
            }

            if (json ["date_updated"] != null && json ["date_updated"] != "null")
            {
                DateUpdated = new DateTime (json ["date_updated"].AsInt);
            }
        }