예제 #1
0
        public static Catalog FromJson(JsonValue json)
        {
            if (json != null)
            {
                var catalog = new Catalog();
                catalog._RawJsonString = json.ToString();

                catalog.Id        = json.GetJsonValue(() => catalog.Id);
                catalog.PageCount = json.GetJsonValue(() => catalog.PageCount);
                catalog.Promoted  = json.GetJsonValue(() => catalog.Promoted);
                catalog.Expires   = json.GetJsonValue(() => catalog.Expires);

                catalog.PublicKey    = json.GetJsonValue(() => catalog.PublicKey);
                catalog.RunFrom      = json.GetJsonValue(() => catalog.RunFrom);
                catalog.RunTill      = json.GetJsonValue(() => catalog.RunTill);
                catalog.SelectStores = json.GetJsonValue(() => catalog.SelectStores);

                catalog.Week = Weeks.FromJson(json);

                catalog.Branding = Branding.FromJson(json);

                catalog.Dealer = Dealer.FromJson(json);
                catalog.Store  = Store.FromJson(json);

                catalog.Images = Images.FromJson(json);

                return(catalog);
            }
            return(null);
        }
        public static Offer FromJson(JsonValue item)
        {
            if (item != null && item.ContainsKey("id"))
            {
                Offer offer = new Offer();
                var   json  = item;
                offer.Id           = json.GetJsonValue(() => offer.Id);
                offer.SelectStores = json.GetJsonValue(() => offer.SelectStores);
                offer.Promoted     = json.GetJsonValue(() => offer.Promoted);
                offer.Heading      = json.GetJsonValue(() => offer.Heading);
                offer.Description  = json.GetJsonValue(() => offer.Description);
                offer.Price        = json.GetJsonValue(() => offer.Price);
                offer.Preprice     = json.GetJsonValue(() => offer.Preprice);
                offer.Images       = Images.FromJson(json);
                offer.Url          = json.GetJsonValue(() => offer.Url);
                offer.RunFrom      = json.GetJsonValue(() => offer.RunFrom);
                offer.RunTill      = json.GetJsonValue(() => offer.RunTill);
                offer.Dealer       = Dealer.FromJson(json);

                //offer.Timespan = Timespan.FromJson(json.GetJsonValue(() => offer.Timespan));

                offer.Catalog = CatalogIndex.FromJson(json);
                offer.Store   = Store.FromJson(json);


                return(offer);
            }
            return(null);
        }
예제 #3
0
        public static Store FromJson(JsonValue item, bool isRoot)
        {
            if (item.ContainsKey("store") || isRoot)
            {
                Store store = new Store();
                var   json  = isRoot ? item : item.GetJsonValue(() => store);

                store._RawJsonString = json.ToString();

                store.City      = json.GetJsonValue(() => store.City);
                store.Dealer    = Dealer.FromJson(json);
                store.Distance  = json.GetJsonValue(() => store.Distance);
                store.Id        = json.GetJsonValue(() => store.Id);
                store.Latitude  = json.GetJsonValue(() => store.Latitude);
                store.Longitude = json.GetJsonValue(() => store.Longitude);
                store.Street    = json.GetJsonValue(() => store.Street);
                store.Zipcode   = json.GetJsonValue(() => store.Zipcode);
                store.Country   = Country.FromJson(json);
                return(store);
            }

            return(null);
        }