Konuyu Oyla:
  • Derecelendirme: 0/5 - 0 oy
  • 1
  • 2
  • 3
  • 4
  • 5
TRestResponse (json olarak) veya TFdMemTable'dan grid bileşenine bilgi aktarımı
#1
Question 
Herkese merhabalar, işlerinde ve projelerinde başarılar.

Bir proje için (FireMonkey uygulaması olacak) WooCommerce API (Wordpress içinde eticaret için kullanılan bir eklenti) kullanarak veri alma ihtiyacım oluştu ancak açıkçası işin içinden tam olarak çıkamadım. Bu konuda sizlere de bir danışmak ve varsa önerilerinizi duymak istedim.

Şimdi konu şu. WooCommerce API kullanarak TRESTClient, T[b]RESTRequest ve TRESTResponse [/b]bileşenleri ile JSON formatındaki bilgiyi başarı ile bir memo bileşenine alıyorum (standart Delphi RestDebuger tarafından oluşturulan bileşenler ile) ve veriyi bir T(String)Grid bileşenine aktarmam gerekiyor. Ancak problem burada başlıyor. Genel örnekler LiveBinding kullanarak TRESTResponseDataSetAdapter üzerinden veriyi TFDMemTable ve daha sonrasında T(String)Grid bileşenine aktarmak ile ilgili. Ve ben LiveBinding kullanmak istemiyorum çünkü;
  1. LiveBinding ile çalıştığımda veri akışı ve olay(Event)lara tam hakim olamıyorum (Ör. her satır bilgi eklendiğinde almam gereken bilgilendirmeler, grid üzerinde yapmam gereken işlemler veya çalıştırmam/kontrol etmem gereken yordamlar mevcut)
  2. LiveBinding yöntemi veriyi tek seferde toptan aktarım yaptığı için görsellik üzerinde yapmam gerekenleri ancak tablo doldurulduktan sonra yapabilirim ki bu benim için ekstra kontrol edilmesi gereken işler çıkartıyor. Halbuki benim veri eklendikçe, eklenen verinin durumuna/türüne/şartlarına göre düzenlemeler yapmam gerekiyor.
Özetle bu yukarıda saydığım şartlar içinde veriyi ya TFDMemTable bileşeninden (direkt veri aktarımı yöntemi ile (EĞER MÜMKÜN ve doğru bir yöntem ise)) ya da [b]TRESTResponse [/b]bileşeninden (JSON verisi üzerinde parse işlemleri yaparak) tane tane T(String)Grid bileşenine aktarmak istiyorum. Öncelikle sorum hangi yöntem daha kolay ve yönetilebilir olur? Bana sanki JSON daha kolay ve sürdürülebilir geliyor ama dediğim gibi sizlerin fikrine ihtiyacım olacak.

Aşağıda standart bir WooCommerce JSON verisinin (benim sistemimden alınmış) örneğini bulabilirsiniz.
[
   {
       "id": 3612,
       "name": "Product 17",
       "slug": "product-17",
       "permalink": "https:\/\/www.siteadress.com\/?post_type=product&p=3612",
       "date_created": "2021-08-29T21:54:04",
       "date_created_gmt": "2021-08-29T18:54:04",
       "date_modified": "2021-12-15T21:52:34",
       "date_modified_gmt": "2021-12-15T18:52:34",
       "type": "simple",
       "status": "pending",
       "featured": false,
       "catalog_visibility": "visible",
       "description": "<p>Product Info<\/p>\n",
       "short_description": "<p>Product Info<\/p>\n",
       "sku": "sku",
       "price": 10,
       "regular_price": 10,
       "sale_price": "",
       "date_on_sale_from": null,
       "date_on_sale_from_gmt": null,
       "date_on_sale_to": null,
       "date_on_sale_to_gmt": null,
       "on_sale": false,
       "purchasable": true,
       "total_sales": 0,
       "virtual": false,
       "downloadable": false,
       "downloads": [
        ],
       "download_limit": 0,
       "download_expiry": 0,
       "external_url": "",
       "button_text": "",
       "tax_status": "taxable",
       "tax_class": "",
       "manage_stock": true,
       "stock_quantity": 10,
       "backorders": "no",
       "backorders_allowed": false,
       "backordered": false,
       "low_stock_amount": null,
       "sold_individually": false,
       "weight": "",
       "dimensions": {
           "length": "",
           "width": "",
           "height": ""
       },
       "shipping_required": true,
       "shipping_taxable": true,
       "shipping_class": "bestmarket-39",
       "shipping_class_id": 52,
       "reviews_allowed": true,
       "average_rating": "0.00",
       "rating_count": 0,
       "upsell_ids": [
        ],
       "cross_sell_ids": [
        ],
       "parent_id": 0,
       "purchase_note": "",
       "categories": [
            {
                "id": 131,
                "name": "Category1",
                "slug": "category1"
            }
        ],
       "tags": [
            {
                "id": 125,
                "name": "tag",
                "slug": "tag"
            }
        ],
       "images": [
        ],
       "attributes": [
        ],
       "default_attributes": [
        ],
       "variations": [
        ],
       "grouped_products": [
        ],
       "menu_order": 0,
       "price_html": "<span class=\"woocommerce-Price-amount amount\"><bdi>10,00<\/bdi><\/span>",
       "related_ids": [
            3497,
            3509,
            3495,
            3501,
            3500
        ],
       "meta_data": [
           {
               "id": 12537,
               "key": "_wp_page_template",
               "value": "default"
           },
           {
               "id": 12538,
               "key": "_elementor_data",
               "value": "[{\"id\":\"69b44582\",\"elType\":\"section\",\"settings\":{\"gap\":\"no\",\"border_border\":\"solid\",\"border_width\":{\"unit\":\"px\",\"top\":\"1\",\"right\":\"1\",\"bottom\":\"1\",\"left\":\"1\",\"isLinked\":false},\"border_color\":\"#E1E1E1\",\"margin\":{\"unit\":\"px\",\"top\":\"-20\",\"right\":0,\"bottom\":\"0\",\"left\":0,\"isLinked\":false},\"padding\":{\"unit\":\"px\",\"top\":\"55\",\"right\":\"40\",\"bottom\":\"55\",\"left\":\"40\",\"isLinked\":false},\"padding_mobile\":{\"unit\":\"px\",\"top\":\"20\",\"right\":\"20\",\"bottom\":\"20\",\"left\":\"20\",\"isLinked\":false}},\"elements\":[{\"id\":\"5c5db240\",\"elType\":\"column\",\"settings\":{\"_column_size\":100,\"_inline_size\":null},\"elements\":[{\"id\":\"29f222b\",\"elType\":\"widget\",\"settings\":{\"editor\":\"There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure anything embarrassing. Suspendisse etiam a suspendisse urna vitae natoque ut a ante vestibulum.\\nQuis commodo consequat feugiat sapien ut tempor laoreet a suspendisse arcu parturient proin nulla tortor inceptos elementum penatibus vestibulum ac in sagittis ac maecenas natoque felis quam. Venenatis varius a quam quis cum placerat.\",\"align\":\"justify\",\"text_color\":\"#777777\",\"typography_typography\":\"custom\",\"typography_font_family\":\"Roboto\",\"typography_font_size\":{\"unit\":\"px\",\"size\":16,\"sizes\":[]},\"typography_font_weight\":\"400\",\"typography_line_height\":{\"unit\":\"px\",\"size\":26,\"sizes\":[]}},\"elements\":[],\"widgetType\":\"text-editor\"},{\"id\":\"60078fb5\",\"elType\":\"widget\",\"settings\":{\"image\":{\"url\":\"https:\\\/\\\/xstore.8theme.com\\\/elementor\\\/demos\\\/niche-market02\\\/wp-content\\\/uploads\\\/sites\\\/55\\\/2020\\\/12\\\/Image-1-3.jpg\",\"id\":651},\"image_size\":\"full\",\"align\":\"center\"},\"elements\":[],\"widgetType\":\"image\"},{\"id\":\"7bbca32f\",\"elType\":\"widget\",\"settings\":{\"editor\":\"Leo elit dui adipiscing ad eleifend congue primis curabitur etiam mi scelerisque nibh habitasse consectetur sapien lacinia condimentum eget. Gravida cubilia justo lacinia scelerisque purus justo orci a vestibulum donec primis suspendisse dignissim class tortor phasellus vestibulum duis ullamcorper natoque leo cursus.\",\"align\":\"justify\",\"text_color\":\"#777777\",\"typography_typography\":\"custom\",\"typography_font_family\":\"Roboto\",\"typography_font_size\":{\"unit\":\"px\",\"size\":16,\"sizes\":[]},\"typography_font_weight\":\"400\",\"typography_line_height\":{\"unit\":\"px\",\"size\":26,\"sizes\":[]}},\"elements\":[],\"widgetType\":\"text-editor\"}],\"isInner\":false}],\"isInner\":false}]"
           },
           {
               "id": 12558,
               "key": "_rightpress_prices",
               "value": "{\"68ce106e\":{\"s\":{\"d9313a78\":{\"p\":\"\",\"t\":1640095584}},\"p\":{\"6265cc5d\":{\"p\":\"10\",\"t\":1640095584}}}}"
           },
           {
               "id": 15198,
               "key": "_alg_wc_cpp_converted_price",
               "value": "10"
           }
       ],
       "stock_status": "instock",
       "etheme_brands": [
        ],
       "_links": {
           "self": [
                {
                    "href": "https:\/\/www.siteadress.com\/wp-json\/wc\/v3\/products\/3612"
                }
            ],
           "collection": [
                {
                    "href": "https:\/\/www.siteadress.com\/wp-json\/wc\/v3\/products"
                }
            ]
       }
   },
   {
       "id": 3611,
       "name": "Product 16",
       "slug": "product-16",
       "permalink": "https:\/\/www.siteadress.com\/?post_type=product&p=3611",
       "date_created": "2021-08-29T21:54:04",
       "date_created_gmt": "2021-08-29T18:54:04",
       "date_modified": "2021-12-15T21:52:34",
       "date_modified_gmt": "2021-12-15T18:52:34",
       "type": "simple",
       "status": "pending",
       "featured": false,
       "catalog_visibility": "visible",
       "description": "<p>Product Info<\/p>\n",
       "short_description": "<p>Product Info<\/p>\n",
       "sku": "sku2",
       "price": 10,
       "regular_price": 10,
       "sale_price": "",
       "date_on_sale_from": null,
       "date_on_sale_from_gmt": null,
       "date_on_sale_to": null,
       "date_on_sale_to_gmt": null,
       "on_sale": false,
       "purchasable": true,
       "total_sales": 0,
       "virtual": false,
       "downloadable": false,
       "downloads": [
        ],
       "download_limit": 0,
       "download_expiry": 0,
       "external_url": "",
       "button_text": "",
       "tax_status": "taxable",
       "tax_class": "",
       "manage_stock": true,
       "stock_quantity": 10,
       "backorders": "no",
       "backorders_allowed": false,
       "backordered": false,
       "low_stock_amount": null,
       "sold_individually": false,
       "weight": "",
       "dimensions": {
           "length": "",
           "width": "",
           "height": ""
       },
       "shipping_required": true,
       "shipping_taxable": true,
       "shipping_class": "bestmarket-39",
       "shipping_class_id": 52,
       "reviews_allowed": true,
       "average_rating": "0.00",
       "rating_count": 0,
       "upsell_ids": [
        ],
       "cross_sell_ids": [
        ],
       "parent_id": 0,
       "purchase_note": "",
       "categories": [
            {
                "id": 131,
                "name": "Category2",
                "slug": "category2"
            }
        ],
       "tags": [
            {
                "id": 125,
                "name": "tag",
                "slug": "tag"
            }
        ],
       "images": [
        ],
       "attributes": [
        ],
       "default_attributes": [
        ],
       "variations": [
        ],
       "grouped_products": [
        ],
       "menu_order": 0,
       "price_html": "<span class=\"woocommerce-Price-amount amount\"><bdi>10,00<\/bdi><\/span>",
       "related_ids": [
            3499,
            3509,
            3507,
            3511,
            3504
        ],
       "meta_data": [
           {
               "id": 12537,
               "key": "_wp_page_template",
               "value": "default"
           },
           {
               "id": 12538,
               "key": "_elementor_data",
               "value": "[{\"id\":\"69b44582\",\"elType\":\"section\",\"settings\":{\"gap\":\"no\",\"border_border\":\"solid\",\"border_width\":{\"unit\":\"px\",\"top\":\"1\",\"right\":\"1\",\"bottom\":\"1\",\"left\":\"1\",\"isLinked\":false},\"border_color\":\"#E1E1E1\",\"margin\":{\"unit\":\"px\",\"top\":\"-20\",\"right\":0,\"bottom\":\"0\",\"left\":0,\"isLinked\":false},\"padding\":{\"unit\":\"px\",\"top\":\"55\",\"right\":\"40\",\"bottom\":\"55\",\"left\":\"40\",\"isLinked\":false},\"padding_mobile\":{\"unit\":\"px\",\"top\":\"20\",\"right\":\"20\",\"bottom\":\"20\",\"left\":\"20\",\"isLinked\":false}},\"elements\":[{\"id\":\"5c5db240\",\"elType\":\"column\",\"settings\":{\"_column_size\":100,\"_inline_size\":null},\"elements\":[{\"id\":\"29f222b\",\"elType\":\"widget\",\"settings\":{\"editor\":\"There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure anything embarrassing. Suspendisse etiam a suspendisse urna vitae natoque ut a ante vestibulum.\\nQuis commodo consequat feugiat sapien ut tempor laoreet a suspendisse arcu parturient proin nulla tortor inceptos elementum penatibus vestibulum ac in sagittis ac maecenas natoque felis quam. Venenatis varius a quam quis cum placerat.\",\"align\":\"justify\",\"text_color\":\"#777777\",\"typography_typography\":\"custom\",\"typography_font_family\":\"Roboto\",\"typography_font_size\":{\"unit\":\"px\",\"size\":16,\"sizes\":[]},\"typography_font_weight\":\"400\",\"typography_line_height\":{\"unit\":\"px\",\"size\":26,\"sizes\":[]}},\"elements\":[],\"widgetType\":\"text-editor\"},{\"id\":\"60078fb5\",\"elType\":\"widget\",\"settings\":{\"image\":{\"url\":\"https:\\\/\\\/xstore.8theme.com\\\/elementor\\\/demos\\\/niche-market02\\\/wp-content\\\/uploads\\\/sites\\\/55\\\/2020\\\/12\\\/Image-1-3.jpg\",\"id\":651},\"image_size\":\"full\",\"align\":\"center\"},\"elements\":[],\"widgetType\":\"image\"},{\"id\":\"7bbca32f\",\"elType\":\"widget\",\"settings\":{\"editor\":\"Leo elit dui adipiscing ad eleifend congue primis curabitur etiam mi scelerisque nibh habitasse consectetur sapien lacinia condimentum eget. Gravida cubilia justo lacinia scelerisque purus justo orci a vestibulum donec primis suspendisse dignissim class tortor phasellus vestibulum duis ullamcorper natoque leo cursus.\",\"align\":\"justify\",\"text_color\":\"#777777\",\"typography_typography\":\"custom\",\"typography_font_family\":\"Roboto\",\"typography_font_size\":{\"unit\":\"px\",\"size\":16,\"sizes\":[]},\"typography_font_weight\":\"400\",\"typography_line_height\":{\"unit\":\"px\",\"size\":26,\"sizes\":[]}},\"elements\":[],\"widgetType\":\"text-editor\"}],\"isInner\":false}],\"isInner\":false}]"
           },
           {
               "id": 12558,
               "key": "_rightpress_prices",
               "value": "{\"68ce106e\":{\"s\":{\"d9313a78\":{\"p\":\"\",\"t\":1640095584}},\"p\":{\"6265cc5d\":{\"p\":\"10\",\"t\":1640095584}}}}"
           },
           {
               "id": 15198,
               "key": "_alg_wc_cpp_converted_price",
               "value": "10"
           }
       ],
       "stock_status": "instock",
       "etheme_brands": [
        ],
       "_links": {
           "self": [
                {
                    "href": "https:\/\/www.siteadress.com\/wp-json\/wc\/v3\/products\/3611"
                }
            ],
           "collection": [
                {
                    "href": "https:\/\/www.siteadress.com\/wp-json\/wc\/v3\/products"
                }
            ]
       }
   }
]

Bana göre en önemli konu herbir nesnenin, dizinin, string, integer, null nesnenin sıra ile analiz edilip ona göre bir yapı oluşturmak gibi geliyor.

Eğer JSON yöntemi daha mantıklı derseniz (verinin kontrol edilmesi, doğrulanması ve gereğinde ek alanlar oluşturulabilmesi gibi konularda, Örneğin; en alttaki _links nesnesi iki adet dizi barındırıyor bu yüzden bu nesnenin alt dizilerini Grid içinde ayrı hücrelerde göstermek istiyorum... gibi) bu yapıdaki bir JSON verisinin olabildiğince otomatik şekilde (çünkü şimdilik JSON bu şekildedir ancak yarın nesnelerin sayısı, türü, ... değişebilir ve hatta üsteki örnekte görebileceğiniz üzere birçok nesne bir ya da daha fazla dizi ve/veya nesne, birçok dizi de bir ya da daha fazla nesne ve/veya dizi barındırabiliyor.) parse edilmesi için önereceğiniz bir kütüphane, bileşen, yol, yordam ver mıdır?


ÖNEMLİ BİLGİLENDİRME: Benim için bunu yaparmısınız gibi bir durum yok sadece belki birilerinin daha önce bu konu ile ilgili bir deneyimi ya da bilgisi vardır veya kullandıkları kütüphane vs. bunu yapıyordur ve beni doğru bilgiye yönlendirebilir mantığı ile bu mesajı yazıyorum.

Daha önce bu konu ile ilgili çok deneyimim olmadı ancak Fesih Bey(@TescilsizUzman )'in kitabına ait eğitim videolarını (3. Hafta (21 Eylül 2019) - Linux Sunucu Uygulaması Yazmak (2. Bölüm)) izleyince konuyu biraz daha anlama şansı buldum. Bu arada buradan ona ve eğitimde (ve tabi kitapta) emeği olanlara teşekkürü borç bilirim.
Cevapla
#2
https://stackoverflow.com/questions/5576...fdmemtable

şurada string in jsona yüklenmesi ve parselenip fdmemtable ye nasıl yükleneceği örneklendirilmiş.

anahtarın alt anahtarı varsa ve onunda alt anahtarı varsa, yani multi array ise bunu fdmemtable nin ftarray ı halledemezsiniz, bu sebeple tavsiyem
ftstring olarak depolamak ve o alanın anahtar adından tekrar string olarak geri okuyup tekrar json objeye atıp anahtarı json komutları ile okumanızdır.

fdmemtable kullanmak delphi objeleri ile birlikde sql query kullanmak adına iyidir ancak kast ettiğiniz eticaret sitesini api üzerinden delphi aplikasyonuna çevirmek ise son derece başınız ağırır.
Cevapla
#3
(29-01-2022, Saat: 19:39)vedat35 Adlı Kullanıcıdan Alıntı: https://stackoverflow.com/questions/5576...fdmemtable

şurada string in jsona yüklenmesi ve parselenip fdmemtable ye nasıl yükleneceği örneklendirilmiş.

anahtarın alt anahtarı varsa ve onunda alt anahtarı varsa, yani multi array ise bunu fdmemtable nin ftarray ı halledemezsiniz, bu sebeple tavsiyem
ftstring olarak depolamak ve o alanın anahtar adından tekrar string olarak geri okuyup tekrar json objeye atıp anahtarı json komutları ile okumanızdır.

fdmemtable kullanmak delphi objeleri ile birlikde sql query kullanmak adına iyidir ancak kast ettiğiniz eticaret sitesini api üzerinden delphi aplikasyonuna çevirmek ise son derece başınız ağırır.
Bende tam olarak sizin söylediğinizi (FdMemTable kullanımının zahmetli ve zorlu yol olacağını) tahmin ettiğim için zaten daha çok JSON veriyi Grid bileşenine aktarma yöntemini denemeyi düşünüyordum, ama ekstra bilgi ve tecrübe her zaman iyidir. Fikir ve bilgi paylaşımınız için teşekkürler.
O zaman geriye eğer varsa bu işi kolaylıkla yapabileceğim bir bileşen/kütüphane ya da yol bulmak kalıyor.
Çözümü bulursam buradan paylaşır haber ederim. Tekrar teşekkürler.
Cevapla
#4
@AlpDmr,
JSON veri grid üzerinde read only olacak ise doğrudan JSON çözümleme ile bilgileri gride aktarın.
Kullanıcı tarafından veriler düzenlenebilir olacaksa, bir TDataSource (TDataset)'e bağlı olmalıdır. 
Bunun en büyük avantajı; Grid üzerinde yapılan tüm işlemler, doğrudan TDateset verileri ile senkronize olacaktır. 
JSON çözümleme için şiddetle jsontodelphi aracını kullanmanızı öneriyorum. Linkte online olarak JSON veriyi doğrudan Delphi class'a dönüştürmeniz sağlanıyor.  Uygulamanın kaynak kodlarına github üzerinden de ulaşabilirsiniz.
Begin : = end / 2;
Cevapla
#5
https://github.com/onryldz/x-superobject
Marshall ile bu yapıyı kullanabilirsin. Fakat öncelikle gelen response'a uygun classlarını oluşturman lazım ki bu ilerde senin içinde rahatlık oluşturacaktır.
İmam Süleyman Yakub <--> Molla Mustafa Mansur
Evlatlarım!
Cismanımız TÜRK ruhumuz ise İSLAM.
Bu yolda daim olalım her an.
Cevapla
#6
Arkadaşlar (b)ilgi için herkese teşekkürler. Aslında önerdiğiniz yollar ve kaynaklar gerçekten harika ancak ben kullanımı biraz daha basit ve kolay adapte edilebilir bir yol arıyordum ki tavsiyelerinizi incelerken de buldum. Sorunu büyük oranda çözdüm ve şu an detaylar üzerinde çalışıyorum.

Kullandığım kütüphane ve bileşeni sisteme tam olarak istediğim şekilde adapte ettikten sonra detayları ve yöntemimi buradan paylaşacağım. Tekrar herkese teşekkürler..
Cevapla
#7
Şu linki -> DTO incelemek isteyebilirsin. 

Dipçe; Test etmedim.

Örnek çıktı : 
unit Root.pas;

interface

uses
 Pkg.Json.DTO, System.Generics.Collections, REST.Json.Types;

{$M+}

type
 TAttributes = class;
 TCategories = class;
 TCollection = class;
 TCrossSellIds = class;
 TDefaultAttributes = class;
 TDimensions = class;
 TDownloads = class;
 TEthemeBrands = class;
 TGroupedProducts = class;
 TImages = class;
 TLinks = class;
 TMetaData = class;
 TSelf = class;
 TTags = class;
 TUpsellIds = class;
 TVariations = class;

 TCollection = class
 private
   [JSONName('href')]
   FHref: string;
 published
   property Href: string read FHref write FHref;
 end;
 
 TSelf = class
 private
   [JSONName('href')]
   FHref: string;
 published
   property Href: string read FHref write FHref;
 end;
 
 TLinks = class(TJsonDTO)
 private
   [JSONName('collection'), JSONMarshalled(False)]
   FCollectionArray: TArray<TCollection>;
   [GenericListReflect]
   FCollection: TObjectList<TCollection>;
   [JSONName('self'), JSONMarshalled(False)]
   FSelfArray: TArray<TSelf>;
   [GenericListReflect]
   FSelf: TObjectList<TSelf>;
   function GetCollection: TObjectList<TCollection>;
   function GetSelf: TObjectList<TSelf>;
 protected
   function GetAsJson: string; override;
 published
   property Collection: TObjectList<TCollection> read GetCollection;
   property Self: TObjectList<TSelf> read GetSelf;
 public
   destructor Destroy; override;
 end;
 
 TEthemeBrands = class
 end;
 
 TMetaData = class
 private
   [JSONName('id')]
   FId: Integer;
   [JSONName('key')]
   FKey: string;
   [JSONName('value')]
   FValue: string;
 published
   property Id: Integer read FId write FId;
   property Key: string read FKey write FKey;
   property Value: string read FValue write FValue;
 end;
 
 TGroupedProducts = class
 end;
 
 TVariations = class
 end;
 
 TDefaultAttributes = class
 end;
 
 TAttributes = class
 end;
 
 TImages = class
 end;
 
 TTags = class
 private
   [JSONName('id')]
   FId: Integer;
   [JSONName('name')]
   FName: string;
   [JSONName('slug')]
   FSlug: string;
 published
   property Id: Integer read FId write FId;
   property Name: string read FName write FName;
   property Slug: string read FSlug write FSlug;
 end;
 
 TCategories = class
 private
   [JSONName('id')]
   FId: Integer;
   [JSONName('name')]
   FName: string;
   [JSONName('slug')]
   FSlug: string;
 published
   property Id: Integer read FId write FId;
   property Name: string read FName write FName;
   property Slug: string read FSlug write FSlug;
 end;
 
 TCrossSellIds = class
 end;
 
 TUpsellIds = class
 end;
 
 TDimensions = class
 private
   [JSONName('height')]
   FHeight: string;
   [JSONName('length')]
   FLength: string;
   [JSONName('width')]
   FWidth: string;
 published
   property Height: string read FHeight write FHeight;
   property Length: string read FLength write FLength;
   property Width: string read FWidth write FWidth;
 end;
 
 TDownloads = class
 end;
 
 TItems = class(TJsonDTO)
 private
   [JSONName('attributes'), JSONMarshalled(False)]
   FAttributesArray: TArray<TAttributes>;
   [GenericListReflect]
   FAttributes: TObjectList<TAttributes>;
   [JSONName('average_rating')]
   FAverageRating: string;
   [JSONName('backordered')]
   FBackordered: Boolean;
   [JSONName('backorders')]
   FBackorders: string;
   [JSONName('backorders_allowed')]
   FBackordersAllowed: Boolean;
   [JSONName('button_text')]
   FButtonText: string;
   [JSONName('catalog_visibility')]
   FCatalogVisibility: string;
   [JSONName('categories'), JSONMarshalled(False)]
   FCategoriesArray: TArray<TCategories>;
   [GenericListReflect]
   FCategories: TObjectList<TCategories>;
   [JSONName('cross_sell_ids'), JSONMarshalled(False)]
   FCrossSellIdsArray: TArray<TCrossSellIds>;
   [GenericListReflect]
   FCrossSellIds: TObjectList<TCrossSellIds>;
   [SuppressZero, JSONName('date_created')]
   FDateCreated: TDateTime;
   [SuppressZero, JSONName('date_created_gmt')]
   FDateCreatedGmt: TDateTime;
   [SuppressZero, JSONName('date_modified')]
   FDateModified: TDateTime;
   [SuppressZero, JSONName('date_modified_gmt')]
   FDateModifiedGmt: TDateTime;
   [JSONName('default_attributes'), JSONMarshalled(False)]
   FDefaultAttributesArray: TArray<TDefaultAttributes>;
   [GenericListReflect]
   FDefaultAttributes: TObjectList<TDefaultAttributes>;
   [JSONName('description')]
   FDescription: string;
   [JSONName('dimensions')]
   FDimensions: TDimensions;
   [JSONName('download_expiry')]
   FDownloadExpiry: Integer;
   [JSONName('download_limit')]
   FDownloadLimit: Integer;
   [JSONName('downloadable')]
   FDownloadable: Boolean;
   [JSONName('downloads'), JSONMarshalled(False)]
   FDownloadsArray: TArray<TDownloads>;
   [GenericListReflect]
   FDownloads: TObjectList<TDownloads>;
   [JSONName('etheme_brands'), JSONMarshalled(False)]
   FEthemeBrandsArray: TArray<TEthemeBrands>;
   [GenericListReflect]
   FEthemeBrands: TObjectList<TEthemeBrands>;
   [JSONName('external_url')]
   FExternalUrl: string;
   [JSONName('featured')]
   FFeatured: Boolean;
   [JSONName('grouped_products'), JSONMarshalled(False)]
   FGroupedProductsArray: TArray<TGroupedProducts>;
   [GenericListReflect]
   FGroupedProducts: TObjectList<TGroupedProducts>;
   [JSONName('id')]
   FId: Integer;
   [JSONName('images'), JSONMarshalled(False)]
   FImagesArray: TArray<TImages>;
   [GenericListReflect]
   FImages: TObjectList<TImages>;
   [JSONName('_links')]
   FLinks: TLinks;
   [JSONName('manage_stock')]
   FManageStock: Boolean;
   [JSONName('menu_order')]
   FMenuOrder: Integer;
   [JSONName('meta_data'), JSONMarshalled(False)]
   FMetaDataArray: TArray<TMetaData>;
   [GenericListReflect]
   FMetaData: TObjectList<TMetaData>;
   [JSONName('name')]
   FName: string;
   [JSONName('on_sale')]
   FOnSale: Boolean;
   [JSONName('parent_id')]
   FParentId: Integer;
   [JSONName('permalink')]
   FPermalink: string;
   [JSONName('price')]
   FPrice: Integer;
   [JSONName('price_html')]
   FPriceHtml: string;
   [JSONName('purchasable')]
   FPurchasable: Boolean;
   [JSONName('purchase_note')]
   FPurchaseNote: string;
   [JSONName('rating_count')]
   FRatingCount: Integer;
   [JSONName('regular_price')]
   FRegularPrice: Integer;
   [JSONName('related_ids')]
   FRelatedIdsArray: TArray<Integer>;
   [JSONMarshalled(False)]
   FRelatedIds: TList<Integer>;
   [JSONName('reviews_allowed')]
   FReviewsAllowed: Boolean;
   [JSONName('sale_price')]
   FSalePrice: string;
   [JSONName('shipping_class')]
   FShippingClass: string;
   [JSONName('shipping_class_id')]
   FShippingClassId: Integer;
   [JSONName('shipping_required')]
   FShippingRequired: Boolean;
   [JSONName('shipping_taxable')]
   FShippingTaxable: Boolean;
   [JSONName('short_description')]
   FShortDescription: string;
   [JSONName('sku')]
   FSku: string;
   [JSONName('slug')]
   FSlug: string;
   [JSONName('sold_individually')]
   FSoldIndividually: Boolean;
   [JSONName('status')]
   FStatus: string;
   [JSONName('stock_quantity')]
   FStockQuantity: Integer;
   [JSONName('stock_status')]
   FStockStatus: string;
   [JSONName('tags'), JSONMarshalled(False)]
   FTagsArray: TArray<TTags>;
   [GenericListReflect]
   FTags: TObjectList<TTags>;
   [JSONName('tax_class')]
   FTaxClass: string;
   [JSONName('tax_status')]
   FTaxStatus: string;
   [JSONName('total_sales')]
   FTotalSales: Integer;
   [JSONName('type')]
   FType: string;
   [JSONName('upsell_ids'), JSONMarshalled(False)]
   FUpsellIdsArray: TArray<TUpsellIds>;
   [GenericListReflect]
   FUpsellIds: TObjectList<TUpsellIds>;
   [JSONName('variations'), JSONMarshalled(False)]
   FVariationsArray: TArray<TVariations>;
   [GenericListReflect]
   FVariations: TObjectList<TVariations>;
   [JSONName('virtual')]
   FVirtual: Boolean;
   [JSONName('weight')]
   FWeight: string;
   function GetAttributes: TObjectList<TAttributes>;
   function GetCategories: TObjectList<TCategories>;
   function GetCrossSellIds: TObjectList<TCrossSellIds>;
   function GetDefaultAttributes: TObjectList<TDefaultAttributes>;
   function GetDownloads: TObjectList<TDownloads>;
   function GetEthemeBrands: TObjectList<TEthemeBrands>;
   function GetGroupedProducts: TObjectList<TGroupedProducts>;
   function GetImages: TObjectList<TImages>;
   function GetMetaData: TObjectList<TMetaData>;
   function GetRelatedIds: TList<Integer>;
   function GetTags: TObjectList<TTags>;
   function GetUpsellIds: TObjectList<TUpsellIds>;
   function GetVariations: TObjectList<TVariations>;
 protected
   function GetAsJson: string; override;
 published
   property Attributes: TObjectList<TAttributes> read GetAttributes;
   property AverageRating: string read FAverageRating write FAverageRating;
   property Backordered: Boolean read FBackordered write FBackordered;
   property Backorders: string read FBackorders write FBackorders;
   property BackordersAllowed: Boolean read FBackordersAllowed write FBackordersAllowed;
   property ButtonText: string read FButtonText write FButtonText;
   property CatalogVisibility: string read FCatalogVisibility write FCatalogVisibility;
   property Categories: TObjectList<TCategories> read GetCategories;
   property CrossSellIds: TObjectList<TCrossSellIds> read GetCrossSellIds;
   property DateCreated: TDateTime read FDateCreated write FDateCreated;
   property DateCreatedGmt: TDateTime read FDateCreatedGmt write FDateCreatedGmt;
   property DateModified: TDateTime read FDateModified write FDateModified;
   property DateModifiedGmt: TDateTime read FDateModifiedGmt write FDateModifiedGmt;
   property DefaultAttributes: TObjectList<TDefaultAttributes> read GetDefaultAttributes;
   property Description: string read FDescription write FDescription;
   property Dimensions: TDimensions read FDimensions;
   property DownloadExpiry: Integer read FDownloadExpiry write FDownloadExpiry;
   property DownloadLimit: Integer read FDownloadLimit write FDownloadLimit;
   property Downloadable: Boolean read FDownloadable write FDownloadable;
   property Downloads: TObjectList<TDownloads> read GetDownloads;
   property EthemeBrands: TObjectList<TEthemeBrands> read GetEthemeBrands;
   property ExternalUrl: string read FExternalUrl write FExternalUrl;
   property Featured: Boolean read FFeatured write FFeatured;
   property GroupedProducts: TObjectList<TGroupedProducts> read GetGroupedProducts;
   property Id: Integer read FId write FId;
   property Images: TObjectList<TImages> read GetImages;
   property Links: TLinks read FLinks;
   property ManageStock: Boolean read FManageStock write FManageStock;
   property MenuOrder: Integer read FMenuOrder write FMenuOrder;
   property MetaData: TObjectList<TMetaData> read GetMetaData;
   property Name: string read FName write FName;
   property OnSale: Boolean read FOnSale write FOnSale;
   property ParentId: Integer read FParentId write FParentId;
   property Permalink: string read FPermalink write FPermalink;
   property Price: Integer read FPrice write FPrice;
   property PriceHtml: string read FPriceHtml write FPriceHtml;
   property Purchasable: Boolean read FPurchasable write FPurchasable;
   property PurchaseNote: string read FPurchaseNote write FPurchaseNote;
   property RatingCount: Integer read FRatingCount write FRatingCount;
   property RegularPrice: Integer read FRegularPrice write FRegularPrice;
   property RelatedIds: TList<Integer> read GetRelatedIds;
   property ReviewsAllowed: Boolean read FReviewsAllowed write FReviewsAllowed;
   property SalePrice: string read FSalePrice write FSalePrice;
   property ShippingClass: string read FShippingClass write FShippingClass;
   property ShippingClassId: Integer read FShippingClassId write FShippingClassId;
   property ShippingRequired: Boolean read FShippingRequired write FShippingRequired;
   property ShippingTaxable: Boolean read FShippingTaxable write FShippingTaxable;
   property ShortDescription: string read FShortDescription write FShortDescription;
   property Sku: string read FSku write FSku;
   property Slug: string read FSlug write FSlug;
   property SoldIndividually: Boolean read FSoldIndividually write FSoldIndividually;
   property Status: string read FStatus write FStatus;
   property StockQuantity: Integer read FStockQuantity write FStockQuantity;
   property StockStatus: string read FStockStatus write FStockStatus;
   property Tags: TObjectList<TTags> read GetTags;
   property TaxClass: string read FTaxClass write FTaxClass;
   property TaxStatus: string read FTaxStatus write FTaxStatus;
   property TotalSales: Integer read FTotalSales write FTotalSales;
   property &Type: string read FType write FType;
   property UpsellIds: TObjectList<TUpsellIds> read GetUpsellIds;
   property Variations: TObjectList<TVariations> read GetVariations;
   property Virtual: Boolean read FVirtual write FVirtual;
   property Weight: string read FWeight write FWeight;
 public
   constructor Create; override;
   destructor Destroy; override;
 end;
 
 TRoot = class(TJsonDTO)
 private
   [JSONName('Items'), JSONMarshalled(False)]
   FItemsArray: TArray<TItems>;
   [GenericListReflect]
   FItems: TObjectList<TItems>;
   function GetItems: TObjectList<TItems>;
 protected
   function GetAsJson: string; override;
 published
   property Items: TObjectList<TItems> read GetItems;
 public
   destructor Destroy; override;
 end;
 
implementation

{ TLinks }

destructor TLinks.Destroy;
begin
 GetCollection.Free;
 GetSelf.Free;
 inherited;
end;

function TLinks.GetCollection: TObjectList<TCollection>;
begin
 Result := ObjectList<TCollection>(FCollection, FCollectionArray);
end;

function TLinks.GetSelf: TObjectList<TSelf>;
begin
 Result := ObjectList<TSelf>(FSelf, FSelfArray);
end;

function TLinks.GetAsJson: string;
begin
 RefreshArray<TCollection>(FCollection, FCollectionArray);
 RefreshArray<TSelf>(FSelf, FSelfArray);
 Result := inherited;
end;

{ TItems }

constructor TItems.Create;
begin
 inherited;
 FDimensions := TDimensions.Create;
 FLinks := TLinks.Create;
end;

destructor TItems.Destroy;
begin
 FDimensions.Free;
 FLinks.Free;
 GetAttributes.Free;
 GetDownloads.Free;
 GetUpsellIds.Free;
 GetCrossSellIds.Free;
 GetCategories.Free;
 GetTags.Free;
 GetImages.Free;
 GetDefaultAttributes.Free;
 GetVariations.Free;
 GetGroupedProducts.Free;
 GetRelatedIds.Free;
 GetMetaData.Free;
 GetEthemeBrands.Free;
 inherited;
end;

function TItems.GetAttributes: TObjectList<TAttributes>;
begin
 Result := ObjectList<TAttributes>(FAttributes, FAttributesArray);
end;

function TItems.GetCategories: TObjectList<TCategories>;
begin
 Result := ObjectList<TCategories>(FCategories, FCategoriesArray);
end;

function TItems.GetCrossSellIds: TObjectList<TCrossSellIds>;
begin
 Result := ObjectList<TCrossSellIds>(FCrossSellIds, FCrossSellIdsArray);
end;

function TItems.GetDefaultAttributes: TObjectList<TDefaultAttributes>;
begin
 Result := ObjectList<TDefaultAttributes>(FDefaultAttributes, FDefaultAttributesArray);
end;

function TItems.GetDownloads: TObjectList<TDownloads>;
begin
 Result := ObjectList<TDownloads>(FDownloads, FDownloadsArray);
end;

function TItems.GetEthemeBrands: TObjectList<TEthemeBrands>;
begin
 Result := ObjectList<TEthemeBrands>(FEthemeBrands, FEthemeBrandsArray);
end;

function TItems.GetGroupedProducts: TObjectList<TGroupedProducts>;
begin
 Result := ObjectList<TGroupedProducts>(FGroupedProducts, FGroupedProductsArray);
end;

function TItems.GetImages: TObjectList<TImages>;
begin
 Result := ObjectList<TImages>(FImages, FImagesArray);
end;

function TItems.GetMetaData: TObjectList<TMetaData>;
begin
 Result := ObjectList<TMetaData>(FMetaData, FMetaDataArray);
end;

function TItems.GetRelatedIds: TList<Integer>;
begin
 Result := List<Integer>(FRelatedIds, FRelatedIdsArray);
end;

function TItems.GetTags: TObjectList<TTags>;
begin
 Result := ObjectList<TTags>(FTags, FTagsArray);
end;

function TItems.GetUpsellIds: TObjectList<TUpsellIds>;
begin
 Result := ObjectList<TUpsellIds>(FUpsellIds, FUpsellIdsArray);
end;

function TItems.GetVariations: TObjectList<TVariations>;
begin
 Result := ObjectList<TVariations>(FVariations, FVariationsArray);
end;

function TItems.GetAsJson: string;
begin
 RefreshArray<TAttributes>(FAttributes, FAttributesArray);
 RefreshArray<TCategories>(FCategories, FCategoriesArray);
 RefreshArray<TCrossSellIds>(FCrossSellIds, FCrossSellIdsArray);
 RefreshArray<TDefaultAttributes>(FDefaultAttributes, FDefaultAttributesArray);
 RefreshArray<TDownloads>(FDownloads, FDownloadsArray);
 RefreshArray<TEthemeBrands>(FEthemeBrands, FEthemeBrandsArray);
 RefreshArray<TGroupedProducts>(FGroupedProducts, FGroupedProductsArray);
 RefreshArray<TImages>(FImages, FImagesArray);
 RefreshArray<TMetaData>(FMetaData, FMetaDataArray);
 RefreshArray<Integer>(FRelatedIds, FRelatedIdsArray);
 RefreshArray<TTags>(FTags, FTagsArray);
 RefreshArray<TUpsellIds>(FUpsellIds, FUpsellIdsArray);
 RefreshArray<TVariations>(FVariations, FVariationsArray);
 Result := inherited;
end;

{ TRoot }

destructor TRoot.Destroy;
begin
 GetItems.Free;
 inherited;
end;

function TRoot.GetItems: TObjectList<TItems>;
begin
 Result := ObjectList<TItems>(FItems, FItemsArray);
end;

function TRoot.GetAsJson: string;
begin
 RefreshArray<TItems>(FItems, FItemsArray);
 Result := inherited;
end;

end.
Amatör Küme Bilgisayar Programcısı
WWW
Cevapla


Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
Information Uygulama yönetici olarak mı çalışıyor? (runtime tespit etme) bakyuz 0 395 28-04-2025, Saat: 17:22
Son Yorum: bakyuz
  Projeye dosya olarak eklenmiş dosyanın içeriğini okumak yhackup 9 1.753 18-04-2025, Saat: 21:39
Son Yorum: bakyuz
  DBGrid1 Alanlarını Gizle Göster Olarak Kullanmak. OZCANK 4 1.075 05-04-2025, Saat: 22:02
Son Yorum: metemet
  Delphi tms vcl ui pack veya alternatifi eroniko 0 568 25-02-2025, Saat: 20:09
Son Yorum: eroniko
  Rest.JSON array serilize hk yhackup 11 1.971 28-11-2024, Saat: 12:35
Son Yorum: delphi.developer



Konuyu Okuyanlar: 1 Ziyaretçi