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ü;
Aşağıda standart bir WooCommerce JSON verisinin (benim sistemimden alınmış) örneğini bulabilirsiniz.
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.
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ü;
- 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)
- 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.
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.


