Konuyu Oyla:
  • Derecelendirme: 0/5 - 0 oy
  • 1
  • 2
  • 3
  • 4
  • 5
json parse
#11
Merhaba,
Delphi XE5 ile birlikte gelen REST.Json kütüphanesi içerisinde tanımlı JsonToObject metodları ile düzenli JSON verilerini doğrudan sınıf yapısına dönüştürebilirsiniz.
JsonToObject  metodu ile vermiş olduğunuz JSON verisindeki birkaç alanı, sınıf yapısına dönüştüren arayüzü paylaşıyorum.
Benzer şekilde diğer alanları bu arayüze ekleyerek, mantığını kavramış olursunuz.

Önemli Not: JSON verisi içerisindeki değer içeren alan adları ile getter/setter adları aynı olmalıdır.
Örneğin, JSON verisindeki KUTU_ADETI alanındaki değeri, sınıfa ait property'e  aktarabilmek için aşağıdaki gibi bir isimlendirme yapmalısınız. Aksi durumda JsonToObject metodu ilgili alanın değerini nereye aktaracağını bilemez.

  private
   FKutu_Adeti : String;
 public
   property KutuAdedi: String read FKutu_Adeti;
 end;

Dikkat ettiyseniz; KUTU_ADETI alanı, FKutu_Adeti olarak tanımlanmıştır.

Not: JSON verisindeki ILAC_BILGISI alanı kayıt dizisi olduğu için Array tipinde tanımlanmalıdır. (Aşağıda örneği mevcut)

Kullanacağınız sınıflar için Unit yapısı:
unit uRecete;

interface

uses Generics.Collections, Rest.Json;

type
 TIlacAd = class
 private
   FValue: String;
 public
   property Value: String read FValue;
 end;

 TIlacBilgisi = class
 private
   FIlac_Adi: TIlacAd;
 public
   property IlacAd: TIlacAd read FIlac_Adi;
   constructor Create;
   destructor Destroy; override;
 end;

 THekimKimlikNumarasi = class
 private
   FValue: String;
 public
   property Value: String read FValue;
 end;

 TReceteTarihi = class
 private
   FValue: String;
 public
   property Value: String read FValue;
 end;

 TReceteBilgisi = class
 private
   FHekim_Kimlik_Numarasi: THekimKimlikNumarasi;
   FIlac_Bilgisi: TArray<TIlacBilgisi>;
   FRecete_Tarihi: TReceteTarihi;
 public
   property HekimKimlikNumarasi: THekimKimlikNumarasi
     read FHekim_Kimlik_Numarasi;
   property IlacBilgisi: TArray<TIlacBilgisi> read FIlac_Bilgisi;
   property ReceteTarihi: TReceteTarihi read FRecete_Tarihi;
   constructor Create;
   destructor Destroy; override;
 end;

 TSonuc = class
 private
   FRecete_Bilgisi: TReceteBilgisi;
 public
   property ReceteBilgisi: TReceteBilgisi read FRecete_Bilgisi;
   constructor Create;
   destructor Destroy; override;
 end;

 TRecete = class
 private
   FDurum: SmallInt;
   FSonuc: TSonuc;
 public
   property Durum: SmallInt read FDurum;
   property Sonuc: TSonuc read FSonuc;
   constructor Create;
   destructor Destroy; override;
   class function JsonToRecete(strJsonRecete: string): TRecete;
 end;

implementation

{ TIlacBilgisi Sınıfı }

constructor TIlacBilgisi.Create;
begin
 inherited;
 FIlac_Adi := TIlacAd.Create();
end;

destructor TIlacBilgisi.Destroy;
begin
 FIlac_Adi.free;
 inherited;
end;

{ TReceteBilgisi Sınıfı }

constructor TReceteBilgisi.Create;
begin
 inherited;
 FRecete_Tarihi := TReceteTarihi.Create();
 FHekim_Kimlik_Numarasi := THekimKimlikNumarasi.Create();
end;

destructor TReceteBilgisi.Destroy;
var
 IlacBilgisi: TIlacBilgisi;
begin

 for IlacBilgisi in FIlac_Bilgisi do
   IlacBilgisi.free;

 FRecete_Tarihi.free;
 FHekim_Kimlik_Numarasi.free;
 inherited;
end;

{ TSonuc Sınıfı }

constructor TSonuc.Create;
begin
 inherited;
 FRecete_Bilgisi := TReceteBilgisi.Create();
end;

destructor TSonuc.Destroy;
begin
 FRecete_Bilgisi.free;
 inherited;
end;

{ TTRecete Sınıfı }

constructor TRecete.Create;
begin
 inherited;
 FSonuc := TSonuc.Create();
end;

destructor TRecete.Destroy;
begin
 FSonuc.free;
 inherited;
end;

class function TRecete.JsonToRecete(strJsonRecete: string): TRecete;
begin
 result := TJson.JsonToObject<TRecete>(strJsonRecete)
end;

end.

Kullanımı aşağıdaki gibidir.
var
 Recete: TRecete;
begin
 Recete := TRecete.Create;
 try
   Recete := Recete.JsonToRecete(Memo2.Text);
   Memo1.Clear;
   Memo1.Lines.Add('Durum: ' + Recete.Durum.ToString);
   Memo1.Lines.Add('Reçete Tarihi: ' +Recete.Sonuc.ReceteBilgisi.ReceteTarihi.value);
   Memo1.Lines.Add('Hekim Kimlik Numarası: ' + Recete.Sonuc.ReceteBilgisi.HekimKimlikNumarasi.value);
   Memo1.Lines.Add('İlaç Adı: ' + Recete.Sonuc.ReceteBilgisi.IlacBilgisi[0].IlacAd.value);
 finally
   FreeAndNil(Recete);
 end;
end;

Örnek Uygulama:

json2.jpg
Cevapla
#12
(12-10-2018, Saat: 09:23)PİRSUS23 Adlı Kullanıcıdan Alıntı: ustadlar tavsiyeleriniz için teşekkür ederim. ben başka yerlerden yardım almaya çalışayım. yine de zaman ayırdığınız için teşekkürler.

Böyle ukela bir cevap üzerine hala yardım için çaba gösteren @"Fesih ARSLAN" beyi tebrik ederim.
WWW
Cevapla
#13
(13-10-2018, Saat: 16:50)yhackup Adlı Kullanıcıdan Alıntı:
(12-10-2018, Saat: 09:23)PİRSUS23 Adlı Kullanıcıdan Alıntı: ustadlar tavsiyeleriniz için teşekkür ederim. ben başka yerlerden yardım almaya çalışayım. yine de zaman ayırdığınız için teşekkürler.

Böyle ukela bir cevap üzerine hala yardım için çaba gösteren @"Fesih ARSLAN"  beyi tebrik ederim.

Dikkatinizden kaçmayan bu ince nüans için teşekkür ederim @yhackup bey.
Karşılığıyla cevap vermeyi de biliyoruz, fakat burda bulunma amacımız kişilerle mücadele değil, teknolojik cehalet ile mücadeledir.
Kendisi ve ben bir gün yok olup gideceğiz, bu bilgi ise gelecek nesildeki DelphiCan'lara kalıcaktır.
Cevapla
#14
(13-10-2018, Saat: 16:50)yhackup Adlı Kullanıcıdan Alıntı:
(12-10-2018, Saat: 09:23)PİRSUS23 Adlı Kullanıcıdan Alıntı: ustadlar tavsiyeleriniz için teşekkür ederim. ben başka yerlerden yardım almaya çalışayım. yine de zaman ayırdığınız için teşekkürler.

Böyle ukela bir cevap üzerine hala yardım için çaba gösteren @"Fesih ARSLAN"  beyi tebrik ederim.

Abi biz bilgi saklıyoruz öyle deme Smile
kisisel_logo_dark.png
WWW
Cevapla
#15
Öncelikle herkese merhabalar... Aşağıdaki JSON'u parse etmeyi bir türlü beceremedim. Gerek forumlarda gerekse netteki araştırmalarım ve denemelerim sonuçsuz kaldı. Çözüm adına önerilerinizi bekler, iyi çalışmalar dilerim...

[
  {
     "id":"5ff06fbd36781450367e2a41",
     "status":400,
     "isScheduled":false,
     "confirmationId":"r392",
     "client":{
        "id":"5f9182d0124a29b457413b28",
        "name":"Mehmet P.",
        "location":{
           "lat":41.0197888,
           "lon":29.040162
        },
        "clientPhoneNumber":"+90 (850) 346-9388882 / 7748873",
        "contactPhoneNumber":"+90 (850) 215-150000",
        "deliveryAddress":{
           "id":"5ff06ebfc5269c7a0345db9a",
           "address":"Altunizade Mah. - Yetimhane Sok., No:1G",
           "aptNo":"",
           "floor":"",
           "doorNo":"",
           "description":""
        }
     },
     "courier":{
        "id":"5dc073faf4d28e09f0377cad",
        "status":100,
        "name":"Restoran Kurye",
        "location":{
           "lat":41.0771112,
           "lon":29.0312168
        }
     },
     "products":[
        {
           "id":"5ff06fbe36781490857e2a44",
           "imageURL":"",
           "wideImageURL":"",
           "count":2,
           "product":"5ede1eddc637a70fae6a4c8b",
           "chainProduct":"",
           "name":{
              "tr":"Ayran",
              "en":"Ayran"
           },
           "price":3,
           "optionPrice":0,
           "priceWithOption":3,
           "totalPrice":6,
           "totalOptionPrice":0,
           "totalPriceWithOption":6,
           "optionCategories":[
               
            ],
           "displayInfo":{
              "title":{
                 "tr":"Ayran",
                 "en":"Ayran"
              },
              "options":{
                 "tr":[
                     
                  ],
                 "en":[
                     
                  ]
              }
           }
        }
     ],
     "clientNote":"",
     "totalPrice":6,
     "checkoutDate":"2021-01-02T14:01:00.793Z",
     "deliveryType":2,
     "doNotKnock":false,
     "isEcoFriendly":false,
     "restaurant":{
        "id":"5ede1dfac637a7cff96a4c7b"
     },
     "paymentMethod":4,
     "paymentMethodText":{
        "en":"On Delivery Cash Payment",
        "tr":"Kap�da Nakit ile �deme"
     }
  }
]

Kullandığım Unit de bu şekildedir... Ancak bu Unit'i kullanarak dataları çekebileceğim fonksiyonu bir türlü yazamadım....


unit RootUnit;

interface

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

{$M+}

type
 TPaymentMethodTextDTO = class
 private
   FEn: string;
   FTr: string;
 published
   property En: string read FEn write FEn;
   property Tr: string read FTr write FTr;
 end;
 
 TRestaurantDTO = class
 private
   FId: string;
 published
   property Id: string read FId write FId;
 end;
 
 TEnDTO = class
 end;
 
 TTrDTO = class
 end;
 
 TOptionsDTO = class
 private
   [JSONName('en')]
   FEnArray: TArray<TEnDTO>;
   [GenericListReflect]
   FEn: TObjectList<TEnDTO>;
   [JSONName('tr')]
   FTrArray: TArray<TTrDTO>;
   [GenericListReflect]
   FTr: TObjectList<TTrDTO>;
   function GetTr: TObjectList<TTrDTO>;
   function GetEn: TObjectList<TEnDTO>;
 published
   property En: TObjectList<TEnDTO> read GetEn;
   property Tr: TObjectList<TTrDTO> read GetTr;
   destructor Destroy; override;
 end;
 
 TTitleDTO = class
 private
   FEn: string;
   FTr: string;
 published
   property En: string read FEn write FEn;
   property Tr: string read FTr write FTr;
 end;
 
 TDisplayInfoDTO = class
 private
   FOptions: TOptionsDTO;
   FTitle: TTitleDTO;
 published
   property Options: TOptionsDTO read FOptions write FOptions;
   property Title: TTitleDTO read FTitle write FTitle;
 public
   constructor Create;
   destructor Destroy; override;
 end;
 
 TOptionCategoriesDTO = class
 end;
 
 TNameDTO = class
 private
   FEn: string;
   FTr: string;
 published
   property En: string read FEn write FEn;
   property Tr: string read FTr write FTr;
 end;
 
 TProductsDTO = class
 private
   FChainProduct: string;
   FCount: Integer;
   FDisplayInfo: TDisplayInfoDTO;
   FId: string;
   FImageURL: string;
   FName: TNameDTO;
   [JSONName('optionCategories')]
   FOptionCategoriesArray: TArray<TOptionCategoriesDTO>;
   [GenericListReflect]
   FOptionCategories: TObjectList<TOptionCategoriesDTO>;
   FOptionPrice: Integer;
   FPrice: Integer;
   FPriceWithOption: Integer;
   FProduct: string;
   FTotalOptionPrice: Integer;
   FTotalPrice: Integer;
   FTotalPriceWithOption: Integer;
   FWideImageURL: string;
   function GetOptionCategories: TObjectList<TOptionCategoriesDTO>;
 published
   property ChainProduct: string read FChainProduct write FChainProduct;
   property Count: Integer read FCount write FCount;
   property DisplayInfo: TDisplayInfoDTO read FDisplayInfo write FDisplayInfo;
   property Id: string read FId write FId;
   property ImageURL: string read FImageURL write FImageURL;
   property Name: TNameDTO read FName write FName;
   property OptionCategories: TObjectList<TOptionCategoriesDTO> read GetOptionCategories;
   property OptionPrice: Integer read FOptionPrice write FOptionPrice;
   property Price: Integer read FPrice write FPrice;
   property PriceWithOption: Integer read FPriceWithOption write FPriceWithOption;
   property Product: string read FProduct write FProduct;
   property TotalOptionPrice: Integer read FTotalOptionPrice write FTotalOptionPrice;
   property TotalPrice: Integer read FTotalPrice write FTotalPrice;
   property TotalPriceWithOption: Integer read FTotalPriceWithOption write FTotalPriceWithOption;
   property WideImageURL: string read FWideImageURL write FWideImageURL;
 public
   constructor Create;
   destructor Destroy; override;
 end;
 
 TLocationDTO_001 = class
 private
   FLat: Double;
   FLon: Double;
 published
   property Lat: Double read FLat write FLat;
   property Lon: Double read FLon write FLon;
 end;
 
 TCourierDTO = class
 private
   FId: string;
   FLocation: TLocationDTO_001;
   FName: string;
   FStatus: Integer;
 published
   property Id: string read FId write FId;
   property Location: TLocationDTO_001 read FLocation write FLocation;
   property Name: string read FName write FName;
   property Status: Integer read FStatus write FStatus;
 public
   constructor Create;
   destructor Destroy; override;
 end;
 
 TDeliveryAddressDTO = class
 private
   FAddress: string;
   FAptNo: string;
   FDescription: string;
   FDoorNo: string;
   FFloor: string;
   FId: string;
 published
   property Address: string read FAddress write FAddress;
   property AptNo: string read FAptNo write FAptNo;
   property Description: string read FDescription write FDescription;
   property DoorNo: string read FDoorNo write FDoorNo;
   property Floor: string read FFloor write FFloor;
   property Id: string read FId write FId;
 end;
 
 TLocationDTO = class
 private
   FLat: Double;
   FLon: Double;
 published
   property Lat: Double read FLat write FLat;
   property Lon: Double read FLon write FLon;
 end;
 
 TClientDTO = class
 private
   FClientPhoneNumber: string;
   FContactPhoneNumber: string;
   FDeliveryAddress: TDeliveryAddressDTO;
   FId: string;
   FLocation: TLocationDTO;
   FName: string;
 published
   property ClientPhoneNumber: string read FClientPhoneNumber write FClientPhoneNumber;
   property ContactPhoneNumber: string read FContactPhoneNumber write FContactPhoneNumber;
   property DeliveryAddress: TDeliveryAddressDTO read FDeliveryAddress write FDeliveryAddress;
   property Id: string read FId write FId;
   property Location: TLocationDTO read FLocation write FLocation;
   property Name: string read FName write FName;
 public
   constructor Create;
   destructor Destroy; override;
 end;
 
 TItemDTO = class
 private
   FCheckoutDate: TDateTime;
   FClient: TClientDTO;
   FClientNote: string;
   FConfirmationId: string;
   FCourier: TCourierDTO;
   FDeliveryType: Integer;
   FDoNotKnock: Boolean;
   FId: string;
   FIsEcoFriendly: Boolean;
   FIsScheduled: Boolean;
   FPaymentMethod: Integer;
   FPaymentMethodText: TPaymentMethodTextDTO;
   [JSONName('products')]
   FProductsArray: TArray<TProductsDTO>;
   [GenericListReflect]
   FProducts: TObjectList<TProductsDTO>;
   FRestaurant: TRestaurantDTO;
   FStatus: Integer;
   FTotalPrice: Integer;
   function GetProducts: TObjectList<TProductsDTO>;
 published
   property CheckoutDate: TDateTime read FCheckoutDate write FCheckoutDate;
   property Client: TClientDTO read FClient write FClient;
   property ClientNote: string read FClientNote write FClientNote;
   property ConfirmationId: string read FConfirmationId write FConfirmationId;
   property Courier: TCourierDTO read FCourier write FCourier;
   property DeliveryType: Integer read FDeliveryType write FDeliveryType;
   property DoNotKnock: Boolean read FDoNotKnock write FDoNotKnock;
   property Id: string read FId write FId;
   property IsEcoFriendly: Boolean read FIsEcoFriendly write FIsEcoFriendly;
   property IsScheduled: Boolean read FIsScheduled write FIsScheduled;
   property PaymentMethod: Integer read FPaymentMethod write FPaymentMethod;
   property PaymentMethodText: TPaymentMethodTextDTO read FPaymentMethodText write FPaymentMethodText;
   property Products: TObjectList<TProductsDTO> read GetProducts;
   property Restaurant: TRestaurantDTO read FRestaurant write FRestaurant;
   property Status: Integer read FStatus write FStatus;
   property TotalPrice: Integer read FTotalPrice write FTotalPrice;
 public
   constructor Create;
   destructor Destroy; override;
 end;
 
 TRootDTO = class(TJsonDTO)
 private
   [JSONName('Items')]
   FItemsArray: TArray<TItemDTO>;
   [GenericListReflect]
   FItems: TObjectList<TItemDTO>;
   function GetItems: TObjectList<TItemDTO>;
 published
   property Items: TObjectList<TItemDTO> read GetItems;
   destructor Destroy; override;
 end;
 
implementation

{ TOptionsDTO }

destructor TOptionsDTO.Destroy;
begin
 GetTr.Free;
 GetEn.Free;
 inherited;
end;

function TOptionsDTO.GetTr: TObjectList<TTrDTO>;
begin
 if not Assigned(FTr) then
 begin
   FTr := TObjectList<TTrDTO>.Create;
   FTr.AddRange(FTrArray);
 end;
 Result := FTr;
end;

function TOptionsDTO.GetEn: TObjectList<TEnDTO>;
begin
 if not Assigned(FEn) then
 begin
   FEn := TObjectList<TEnDTO>.Create;
   FEn.AddRange(FEnArray);
 end;
 Result := FEn;
end;

{ TDisplayInfoDTO }

constructor TDisplayInfoDTO.Create;
begin
 inherited;
 FTitle := TTitleDTO.Create;
 FOptions := TOptionsDTO.Create;
end;

destructor TDisplayInfoDTO.Destroy;
begin
 FTitle.Free;
 FOptions.Free;
 inherited;
end;

{ TProductsDTO }

constructor TProductsDTO.Create;
begin
 inherited;
 FName := TNameDTO.Create;
 FDisplayInfo := TDisplayInfoDTO.Create;
end;

destructor TProductsDTO.Destroy;
begin
 FName.Free;
 FDisplayInfo.Free;
 GetOptionCategories.Free;
 inherited;
end;

function TProductsDTO.GetOptionCategories: TObjectList<TOptionCategoriesDTO>;
begin
 if not Assigned(FOptionCategories) then
 begin
   FOptionCategories := TObjectList<TOptionCategoriesDTO>.Create;
   FOptionCategories.AddRange(FOptionCategoriesArray);
 end;
 Result := FOptionCategories;
end;

{ TCourierDTO }

constructor TCourierDTO.Create;
begin
 inherited;
 FLocation := TLocationDTO_001.Create;
end;

destructor TCourierDTO.Destroy;
begin
 FLocation.Free;
 inherited;
end;

{ TClientDTO }

constructor TClientDTO.Create;
begin
 inherited;
 FLocation := TLocationDTO.Create;
 FDeliveryAddress := TDeliveryAddressDTO.Create;
end;

destructor TClientDTO.Destroy;
begin
 FLocation.Free;
 FDeliveryAddress.Free;
 inherited;
end;

{ TItemDTO }

constructor TItemDTO.Create;
begin
 inherited;
 FClient := TClientDTO.Create;
 FCourier := TCourierDTO.Create;
 FRestaurant := TRestaurantDTO.Create;
 FPaymentMethodText := TPaymentMethodTextDTO.Create;
end;

destructor TItemDTO.Destroy;
begin
 FClient.Free;
 FCourier.Free;
 FRestaurant.Free;
 FPaymentMethodText.Free;
 GetProducts.Free;
 inherited;
end;

function TItemDTO.GetProducts: TObjectList<TProductsDTO>;
begin
 if not Assigned(FProducts) then
 begin
   FProducts := TObjectList<TProductsDTO>.Create;
   FProducts.AddRange(FProductsArray);
 end;
 Result := FProducts;
end;

{ TRootDTO }

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

function TRootDTO.GetItems: TObjectList<TItemDTO>;
begin
 if not Assigned(FItems) then
 begin
   FItems := TObjectList<TItemDTO>.Create;
   FItems.AddRange(FItemsArray);
 end;
 Result := FItems;
end;

end.
Cevapla
#16
(08-01-2021, Saat: 04:22)tmrksmt Adlı Kullanıcıdan Alıntı: Öncelikle herkese merhabalar... Aşağıdaki JSON'u parse etmeyi bir türlü beceremedim. Gerek forumlarda gerekse netteki araştırmalarım ve denemelerim sonuçsuz kaldı. Çözüm adına önerilerinizi bekler, iyi çalışmalar dilerim...

[
  {
     "id":"5ff06fbd36781450367e2a41",
     "status":400,
     "isScheduled":false,
     "confirmationId":"r392",
     "client":{
        "id":"5f9182d0124a29b457413b28",
        "name":"Mehmet P.",
        "location":{
           "lat":41.0197888,
           "lon":29.040162
        },
        "clientPhoneNumber":"+90 (850) 346-9388882 / 7748873",
        "contactPhoneNumber":"+90 (850) 215-150000",
        "deliveryAddress":{
           "id":"5ff06ebfc5269c7a0345db9a",
           "address":"Altunizade Mah. - Yetimhane Sok., No:1G",
           "aptNo":"",
           "floor":"",
           "doorNo":"",
           "description":""
        }
     },
     "courier":{
        "id":"5dc073faf4d28e09f0377cad",
        "status":100,
        "name":"Restoran Kurye",
        "location":{
           "lat":41.0771112,
           "lon":29.0312168
        }
     },
     "products":[
        {
           "id":"5ff06fbe36781490857e2a44",
           "imageURL":"",
           "wideImageURL":"",
           "count":2,
           "product":"5ede1eddc637a70fae6a4c8b",
           "chainProduct":"",
           "name":{
              "tr":"Ayran",
              "en":"Ayran"
           },
           "price":3,
           "optionPrice":0,
           "priceWithOption":3,
           "totalPrice":6,
           "totalOptionPrice":0,
           "totalPriceWithOption":6,
           "optionCategories":[
               
            ],
           "displayInfo":{
              "title":{
                 "tr":"Ayran",
                 "en":"Ayran"
              },
              "options":{
                 "tr":[
                     
                  ],
                 "en":[
                     
                  ]
              }
           }
        }
     ],
     "clientNote":"",
     "totalPrice":6,
     "checkoutDate":"2021-01-02T14:01:00.793Z",
     "deliveryType":2,
     "doNotKnock":false,
     "isEcoFriendly":false,
     "restaurant":{
        "id":"5ede1dfac637a7cff96a4c7b"
     },
     "paymentMethod":4,
     "paymentMethodText":{
        "en":"On Delivery Cash Payment",
        "tr":"Kap�da Nakit ile �deme"
     }
  }
]

Kullandığım Unit de bu şekildedir... Ancak bu Unit'i kullanarak dataları çekebileceğim fonksiyonu bir türlü yazamadım....


unit RootUnit;

interface

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

{$M+}

type
 TPaymentMethodTextDTO = class
 private
   FEn: string;
   FTr: string;
 published
   property En: string read FEn write FEn;
   property Tr: string read FTr write FTr;
 end;
 
 TRestaurantDTO = class
 private
   FId: string;
 published
   property Id: string read FId write FId;
 end;
 
 TEnDTO = class
 end;
 
 TTrDTO = class
 end;
 
 TOptionsDTO = class
 private
   [JSONName('en')]
   FEnArray: TArray<TEnDTO>;
   [GenericListReflect]
   FEn: TObjectList<TEnDTO>;
   [JSONName('tr')]
   FTrArray: TArray<TTrDTO>;
   [GenericListReflect]
   FTr: TObjectList<TTrDTO>;
   function GetTr: TObjectList<TTrDTO>;
   function GetEn: TObjectList<TEnDTO>;
 published
   property En: TObjectList<TEnDTO> read GetEn;
   property Tr: TObjectList<TTrDTO> read GetTr;
   destructor Destroy; override;
 end;
 
 TTitleDTO = class
 private
   FEn: string;
   FTr: string;
 published
   property En: string read FEn write FEn;
   property Tr: string read FTr write FTr;
 end;
 
 TDisplayInfoDTO = class
 private
   FOptions: TOptionsDTO;
   FTitle: TTitleDTO;
 published
   property Options: TOptionsDTO read FOptions write FOptions;
   property Title: TTitleDTO read FTitle write FTitle;
 public
   constructor Create;
   destructor Destroy; override;
 end;
 
 TOptionCategoriesDTO = class
 end;
 
 TNameDTO = class
 private
   FEn: string;
   FTr: string;
 published
   property En: string read FEn write FEn;
   property Tr: string read FTr write FTr;
 end;
 
 TProductsDTO = class
 private
   FChainProduct: string;
   FCount: Integer;
   FDisplayInfo: TDisplayInfoDTO;
   FId: string;
   FImageURL: string;
   FName: TNameDTO;
   [JSONName('optionCategories')]
   FOptionCategoriesArray: TArray<TOptionCategoriesDTO>;
   [GenericListReflect]
   FOptionCategories: TObjectList<TOptionCategoriesDTO>;
   FOptionPrice: Integer;
   FPrice: Integer;
   FPriceWithOption: Integer;
   FProduct: string;
   FTotalOptionPrice: Integer;
   FTotalPrice: Integer;
   FTotalPriceWithOption: Integer;
   FWideImageURL: string;
   function GetOptionCategories: TObjectList<TOptionCategoriesDTO>;
 published
   property ChainProduct: string read FChainProduct write FChainProduct;
   property Count: Integer read FCount write FCount;
   property DisplayInfo: TDisplayInfoDTO read FDisplayInfo write FDisplayInfo;
   property Id: string read FId write FId;
   property ImageURL: string read FImageURL write FImageURL;
   property Name: TNameDTO read FName write FName;
   property OptionCategories: TObjectList<TOptionCategoriesDTO> read GetOptionCategories;
   property OptionPrice: Integer read FOptionPrice write FOptionPrice;
   property Price: Integer read FPrice write FPrice;
   property PriceWithOption: Integer read FPriceWithOption write FPriceWithOption;
   property Product: string read FProduct write FProduct;
   property TotalOptionPrice: Integer read FTotalOptionPrice write FTotalOptionPrice;
   property TotalPrice: Integer read FTotalPrice write FTotalPrice;
   property TotalPriceWithOption: Integer read FTotalPriceWithOption write FTotalPriceWithOption;
   property WideImageURL: string read FWideImageURL write FWideImageURL;
 public
   constructor Create;
   destructor Destroy; override;
 end;
 
 TLocationDTO_001 = class
 private
   FLat: Double;
   FLon: Double;
 published
   property Lat: Double read FLat write FLat;
   property Lon: Double read FLon write FLon;
 end;
 
 TCourierDTO = class
 private
   FId: string;
   FLocation: TLocationDTO_001;
   FName: string;
   FStatus: Integer;
 published
   property Id: string read FId write FId;
   property Location: TLocationDTO_001 read FLocation write FLocation;
   property Name: string read FName write FName;
   property Status: Integer read FStatus write FStatus;
 public
   constructor Create;
   destructor Destroy; override;
 end;
 
 TDeliveryAddressDTO = class
 private
   FAddress: string;
   FAptNo: string;
   FDescription: string;
   FDoorNo: string;
   FFloor: string;
   FId: string;
 published
   property Address: string read FAddress write FAddress;
   property AptNo: string read FAptNo write FAptNo;
   property Description: string read FDescription write FDescription;
   property DoorNo: string read FDoorNo write FDoorNo;
   property Floor: string read FFloor write FFloor;
   property Id: string read FId write FId;
 end;
 
 TLocationDTO = class
 private
   FLat: Double;
   FLon: Double;
 published
   property Lat: Double read FLat write FLat;
   property Lon: Double read FLon write FLon;
 end;
 
 TClientDTO = class
 private
   FClientPhoneNumber: string;
   FContactPhoneNumber: string;
   FDeliveryAddress: TDeliveryAddressDTO;
   FId: string;
   FLocation: TLocationDTO;
   FName: string;
 published
   property ClientPhoneNumber: string read FClientPhoneNumber write FClientPhoneNumber;
   property ContactPhoneNumber: string read FContactPhoneNumber write FContactPhoneNumber;
   property DeliveryAddress: TDeliveryAddressDTO read FDeliveryAddress write FDeliveryAddress;
   property Id: string read FId write FId;
   property Location: TLocationDTO read FLocation write FLocation;
   property Name: string read FName write FName;
 public
   constructor Create;
   destructor Destroy; override;
 end;
 
 TItemDTO = class
 private
   FCheckoutDate: TDateTime;
   FClient: TClientDTO;
   FClientNote: string;
   FConfirmationId: string;
   FCourier: TCourierDTO;
   FDeliveryType: Integer;
   FDoNotKnock: Boolean;
   FId: string;
   FIsEcoFriendly: Boolean;
   FIsScheduled: Boolean;
   FPaymentMethod: Integer;
   FPaymentMethodText: TPaymentMethodTextDTO;
   [JSONName('products')]
   FProductsArray: TArray<TProductsDTO>;
   [GenericListReflect]
   FProducts: TObjectList<TProductsDTO>;
   FRestaurant: TRestaurantDTO;
   FStatus: Integer;
   FTotalPrice: Integer;
   function GetProducts: TObjectList<TProductsDTO>;
 published
   property CheckoutDate: TDateTime read FCheckoutDate write FCheckoutDate;
   property Client: TClientDTO read FClient write FClient;
   property ClientNote: string read FClientNote write FClientNote;
   property ConfirmationId: string read FConfirmationId write FConfirmationId;
   property Courier: TCourierDTO read FCourier write FCourier;
   property DeliveryType: Integer read FDeliveryType write FDeliveryType;
   property DoNotKnock: Boolean read FDoNotKnock write FDoNotKnock;
   property Id: string read FId write FId;
   property IsEcoFriendly: Boolean read FIsEcoFriendly write FIsEcoFriendly;
   property IsScheduled: Boolean read FIsScheduled write FIsScheduled;
   property PaymentMethod: Integer read FPaymentMethod write FPaymentMethod;
   property PaymentMethodText: TPaymentMethodTextDTO read FPaymentMethodText write FPaymentMethodText;
   property Products: TObjectList<TProductsDTO> read GetProducts;
   property Restaurant: TRestaurantDTO read FRestaurant write FRestaurant;
   property Status: Integer read FStatus write FStatus;
   property TotalPrice: Integer read FTotalPrice write FTotalPrice;
 public
   constructor Create;
   destructor Destroy; override;
 end;
 
 TRootDTO = class(TJsonDTO)
 private
   [JSONName('Items')]
   FItemsArray: TArray<TItemDTO>;
   [GenericListReflect]
   FItems: TObjectList<TItemDTO>;
   function GetItems: TObjectList<TItemDTO>;
 published
   property Items: TObjectList<TItemDTO> read GetItems;
   destructor Destroy; override;
 end;
 
implementation

{ TOptionsDTO }

destructor TOptionsDTO.Destroy;
begin
 GetTr.Free;
 GetEn.Free;
 inherited;
end;

function TOptionsDTO.GetTr: TObjectList<TTrDTO>;
begin
 if not Assigned(FTr) then
 begin
   FTr := TObjectList<TTrDTO>.Create;
   FTr.AddRange(FTrArray);
 end;
 Result := FTr;
end;

function TOptionsDTO.GetEn: TObjectList<TEnDTO>;
begin
 if not Assigned(FEn) then
 begin
   FEn := TObjectList<TEnDTO>.Create;
   FEn.AddRange(FEnArray);
 end;
 Result := FEn;
end;

{ TDisplayInfoDTO }

constructor TDisplayInfoDTO.Create;
begin
 inherited;
 FTitle := TTitleDTO.Create;
 FOptions := TOptionsDTO.Create;
end;

destructor TDisplayInfoDTO.Destroy;
begin
 FTitle.Free;
 FOptions.Free;
 inherited;
end;

{ TProductsDTO }

constructor TProductsDTO.Create;
begin
 inherited;
 FName := TNameDTO.Create;
 FDisplayInfo := TDisplayInfoDTO.Create;
end;

destructor TProductsDTO.Destroy;
begin
 FName.Free;
 FDisplayInfo.Free;
 GetOptionCategories.Free;
 inherited;
end;

function TProductsDTO.GetOptionCategories: TObjectList<TOptionCategoriesDTO>;
begin
 if not Assigned(FOptionCategories) then
 begin
   FOptionCategories := TObjectList<TOptionCategoriesDTO>.Create;
   FOptionCategories.AddRange(FOptionCategoriesArray);
 end;
 Result := FOptionCategories;
end;

{ TCourierDTO }

constructor TCourierDTO.Create;
begin
 inherited;
 FLocation := TLocationDTO_001.Create;
end;

destructor TCourierDTO.Destroy;
begin
 FLocation.Free;
 inherited;
end;

{ TClientDTO }

constructor TClientDTO.Create;
begin
 inherited;
 FLocation := TLocationDTO.Create;
 FDeliveryAddress := TDeliveryAddressDTO.Create;
end;

destructor TClientDTO.Destroy;
begin
 FLocation.Free;
 FDeliveryAddress.Free;
 inherited;
end;

{ TItemDTO }

constructor TItemDTO.Create;
begin
 inherited;
 FClient := TClientDTO.Create;
 FCourier := TCourierDTO.Create;
 FRestaurant := TRestaurantDTO.Create;
 FPaymentMethodText := TPaymentMethodTextDTO.Create;
end;

destructor TItemDTO.Destroy;
begin
 FClient.Free;
 FCourier.Free;
 FRestaurant.Free;
 FPaymentMethodText.Free;
 GetProducts.Free;
 inherited;
end;

function TItemDTO.GetProducts: TObjectList<TProductsDTO>;
begin
 if not Assigned(FProducts) then
 begin
   FProducts := TObjectList<TProductsDTO>.Create;
   FProducts.AddRange(FProductsArray);
 end;
 Result := FProducts;
end;

{ TRootDTO }

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

function TRootDTO.GetItems: TObjectList<TItemDTO>;
begin
 if not Assigned(FItems) then
 begin
   FItems := TObjectList<TItemDTO>.Create;
   FItems.AddRange(FItemsArray);
 end;
 Result := FItems;
end;

end.


   

Ayran biraz pahalı değil mi?   Exclamation

Örnek uygulama unit'leri:

.zip   UrunSiparis.zip (Dosya Boyutu: 3,49 KB / İndirme Sayısı: 32)
Begin : = end / 2;
Cevapla
#17
(08-01-2021, Saat: 10:01)RAD Coder Adlı Kullanıcıdan Alıntı:
(08-01-2021, Saat: 04:22)tmrksmt Adlı Kullanıcıdan Alıntı: Öncelikle herkese merhabalar... Aşağıdaki JSON'u parse etmeyi bir türlü beceremedim. Gerek forumlarda gerekse netteki araştırmalarım ve denemelerim sonuçsuz kaldı. Çözüm adına önerilerinizi bekler, iyi çalışmalar dilerim...

[
  {
     "id":"5ff06fbd36781450367e2a41",
     "status":400,
     "isScheduled":false,
     "confirmationId":"r392",
     "client":{
        "id":"5f9182d0124a29b457413b28",
        "name":"Mehmet P.",
        "location":{
           "lat":41.0197888,
           "lon":29.040162
        },
        "clientPhoneNumber":"+90 (850) 346-9388882 / 7748873",
        "contactPhoneNumber":"+90 (850) 215-150000",
        "deliveryAddress":{
           "id":"5ff06ebfc5269c7a0345db9a",
           "address":"Altunizade Mah. - Yetimhane Sok., No:1G",
           "aptNo":"",
           "floor":"",
           "doorNo":"",
           "description":""
        }
     },
     "courier":{
        "id":"5dc073faf4d28e09f0377cad",
        "status":100,
        "name":"Restoran Kurye",
        "location":{
           "lat":41.0771112,
           "lon":29.0312168
        }
     },
     "products":[
        {
           "id":"5ff06fbe36781490857e2a44",
           "imageURL":"",
           "wideImageURL":"",
           "count":2,
           "product":"5ede1eddc637a70fae6a4c8b",
           "chainProduct":"",
           "name":{
              "tr":"Ayran",
              "en":"Ayran"
           },
           "price":3,
           "optionPrice":0,
           "priceWithOption":3,
           "totalPrice":6,
           "totalOptionPrice":0,
           "totalPriceWithOption":6,
           "optionCategories":[
               
            ],
           "displayInfo":{
              "title":{
                 "tr":"Ayran",
                 "en":"Ayran"
              },
              "options":{
                 "tr":[
                     
                  ],
                 "en":[
                     
                  ]
              }
           }
        }
     ],
     "clientNote":"",
     "totalPrice":6,
     "checkoutDate":"2021-01-02T14:01:00.793Z",
     "deliveryType":2,
     "doNotKnock":false,
     "isEcoFriendly":false,
     "restaurant":{
        "id":"5ede1dfac637a7cff96a4c7b"
     },
     "paymentMethod":4,
     "paymentMethodText":{
        "en":"On Delivery Cash Payment",
        "tr":"Kap�da Nakit ile �deme"
     }
  }
]

Kullandığım Unit de bu şekildedir... Ancak bu Unit'i kullanarak dataları çekebileceğim fonksiyonu bir türlü yazamadım....


unit RootUnit;

interface

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

{$M+}

type
 TPaymentMethodTextDTO = class
 private
   FEn: string;
   FTr: string;
 published
   property En: string read FEn write FEn;
   property Tr: string read FTr write FTr;
 end;
 
 TRestaurantDTO = class
 private
   FId: string;
 published
   property Id: string read FId write FId;
 end;
 
 TEnDTO = class
 end;
 
 TTrDTO = class
 end;
 
 TOptionsDTO = class
 private
   [JSONName('en')]
   FEnArray: TArray<TEnDTO>;
   [GenericListReflect]
   FEn: TObjectList<TEnDTO>;
   [JSONName('tr')]
   FTrArray: TArray<TTrDTO>;
   [GenericListReflect]
   FTr: TObjectList<TTrDTO>;
   function GetTr: TObjectList<TTrDTO>;
   function GetEn: TObjectList<TEnDTO>;
 published
   property En: TObjectList<TEnDTO> read GetEn;
   property Tr: TObjectList<TTrDTO> read GetTr;
   destructor Destroy; override;
 end;
 
 TTitleDTO = class
 private
   FEn: string;
   FTr: string;
 published
   property En: string read FEn write FEn;
   property Tr: string read FTr write FTr;
 end;
 
 TDisplayInfoDTO = class
 private
   FOptions: TOptionsDTO;
   FTitle: TTitleDTO;
 published
   property Options: TOptionsDTO read FOptions write FOptions;
   property Title: TTitleDTO read FTitle write FTitle;
 public
   constructor Create;
   destructor Destroy; override;
 end;
 
 TOptionCategoriesDTO = class
 end;
 
 TNameDTO = class
 private
   FEn: string;
   FTr: string;
 published
   property En: string read FEn write FEn;
   property Tr: string read FTr write FTr;
 end;
 
 TProductsDTO = class
 private
   FChainProduct: string;
   FCount: Integer;
   FDisplayInfo: TDisplayInfoDTO;
   FId: string;
   FImageURL: string;
   FName: TNameDTO;
   [JSONName('optionCategories')]
   FOptionCategoriesArray: TArray<TOptionCategoriesDTO>;
   [GenericListReflect]
   FOptionCategories: TObjectList<TOptionCategoriesDTO>;
   FOptionPrice: Integer;
   FPrice: Integer;
   FPriceWithOption: Integer;
   FProduct: string;
   FTotalOptionPrice: Integer;
   FTotalPrice: Integer;
   FTotalPriceWithOption: Integer;
   FWideImageURL: string;
   function GetOptionCategories: TObjectList<TOptionCategoriesDTO>;
 published
   property ChainProduct: string read FChainProduct write FChainProduct;
   property Count: Integer read FCount write FCount;
   property DisplayInfo: TDisplayInfoDTO read FDisplayInfo write FDisplayInfo;
   property Id: string read FId write FId;
   property ImageURL: string read FImageURL write FImageURL;
   property Name: TNameDTO read FName write FName;
   property OptionCategories: TObjectList<TOptionCategoriesDTO> read GetOptionCategories;
   property OptionPrice: Integer read FOptionPrice write FOptionPrice;
   property Price: Integer read FPrice write FPrice;
   property PriceWithOption: Integer read FPriceWithOption write FPriceWithOption;
   property Product: string read FProduct write FProduct;
   property TotalOptionPrice: Integer read FTotalOptionPrice write FTotalOptionPrice;
   property TotalPrice: Integer read FTotalPrice write FTotalPrice;
   property TotalPriceWithOption: Integer read FTotalPriceWithOption write FTotalPriceWithOption;
   property WideImageURL: string read FWideImageURL write FWideImageURL;
 public
   constructor Create;
   destructor Destroy; override;
 end;
 
 TLocationDTO_001 = class
 private
   FLat: Double;
   FLon: Double;
 published
   property Lat: Double read FLat write FLat;
   property Lon: Double read FLon write FLon;
 end;
 
 TCourierDTO = class
 private
   FId: string;
   FLocation: TLocationDTO_001;
   FName: string;
   FStatus: Integer;
 published
   property Id: string read FId write FId;
   property Location: TLocationDTO_001 read FLocation write FLocation;
   property Name: string read FName write FName;
   property Status: Integer read FStatus write FStatus;
 public
   constructor Create;
   destructor Destroy; override;
 end;
 
 TDeliveryAddressDTO = class
 private
   FAddress: string;
   FAptNo: string;
   FDescription: string;
   FDoorNo: string;
   FFloor: string;
   FId: string;
 published
   property Address: string read FAddress write FAddress;
   property AptNo: string read FAptNo write FAptNo;
   property Description: string read FDescription write FDescription;
   property DoorNo: string read FDoorNo write FDoorNo;
   property Floor: string read FFloor write FFloor;
   property Id: string read FId write FId;
 end;
 
 TLocationDTO = class
 private
   FLat: Double;
   FLon: Double;
 published
   property Lat: Double read FLat write FLat;
   property Lon: Double read FLon write FLon;
 end;
 
 TClientDTO = class
 private
   FClientPhoneNumber: string;
   FContactPhoneNumber: string;
   FDeliveryAddress: TDeliveryAddressDTO;
   FId: string;
   FLocation: TLocationDTO;
   FName: string;
 published
   property ClientPhoneNumber: string read FClientPhoneNumber write FClientPhoneNumber;
   property ContactPhoneNumber: string read FContactPhoneNumber write FContactPhoneNumber;
   property DeliveryAddress: TDeliveryAddressDTO read FDeliveryAddress write FDeliveryAddress;
   property Id: string read FId write FId;
   property Location: TLocationDTO read FLocation write FLocation;
   property Name: string read FName write FName;
 public
   constructor Create;
   destructor Destroy; override;
 end;
 
 TItemDTO = class
 private
   FCheckoutDate: TDateTime;
   FClient: TClientDTO;
   FClientNote: string;
   FConfirmationId: string;
   FCourier: TCourierDTO;
   FDeliveryType: Integer;
   FDoNotKnock: Boolean;
   FId: string;
   FIsEcoFriendly: Boolean;
   FIsScheduled: Boolean;
   FPaymentMethod: Integer;
   FPaymentMethodText: TPaymentMethodTextDTO;
   [JSONName('products')]
   FProductsArray: TArray<TProductsDTO>;
   [GenericListReflect]
   FProducts: TObjectList<TProductsDTO>;
   FRestaurant: TRestaurantDTO;
   FStatus: Integer;
   FTotalPrice: Integer;
   function GetProducts: TObjectList<TProductsDTO>;
 published
   property CheckoutDate: TDateTime read FCheckoutDate write FCheckoutDate;
   property Client: TClientDTO read FClient write FClient;
   property ClientNote: string read FClientNote write FClientNote;
   property ConfirmationId: string read FConfirmationId write FConfirmationId;
   property Courier: TCourierDTO read FCourier write FCourier;
   property DeliveryType: Integer read FDeliveryType write FDeliveryType;
   property DoNotKnock: Boolean read FDoNotKnock write FDoNotKnock;
   property Id: string read FId write FId;
   property IsEcoFriendly: Boolean read FIsEcoFriendly write FIsEcoFriendly;
   property IsScheduled: Boolean read FIsScheduled write FIsScheduled;
   property PaymentMethod: Integer read FPaymentMethod write FPaymentMethod;
   property PaymentMethodText: TPaymentMethodTextDTO read FPaymentMethodText write FPaymentMethodText;
   property Products: TObjectList<TProductsDTO> read GetProducts;
   property Restaurant: TRestaurantDTO read FRestaurant write FRestaurant;
   property Status: Integer read FStatus write FStatus;
   property TotalPrice: Integer read FTotalPrice write FTotalPrice;
 public
   constructor Create;
   destructor Destroy; override;
 end;
 
 TRootDTO = class(TJsonDTO)
 private
   [JSONName('Items')]
   FItemsArray: TArray<TItemDTO>;
   [GenericListReflect]
   FItems: TObjectList<TItemDTO>;
   function GetItems: TObjectList<TItemDTO>;
 published
   property Items: TObjectList<TItemDTO> read GetItems;
   destructor Destroy; override;
 end;
 
implementation

{ TOptionsDTO }

destructor TOptionsDTO.Destroy;
begin
 GetTr.Free;
 GetEn.Free;
 inherited;
end;

function TOptionsDTO.GetTr: TObjectList<TTrDTO>;
begin
 if not Assigned(FTr) then
 begin
   FTr := TObjectList<TTrDTO>.Create;
   FTr.AddRange(FTrArray);
 end;
 Result := FTr;
end;

function TOptionsDTO.GetEn: TObjectList<TEnDTO>;
begin
 if not Assigned(FEn) then
 begin
   FEn := TObjectList<TEnDTO>.Create;
   FEn.AddRange(FEnArray);
 end;
 Result := FEn;
end;

{ TDisplayInfoDTO }

constructor TDisplayInfoDTO.Create;
begin
 inherited;
 FTitle := TTitleDTO.Create;
 FOptions := TOptionsDTO.Create;
end;

destructor TDisplayInfoDTO.Destroy;
begin
 FTitle.Free;
 FOptions.Free;
 inherited;
end;

{ TProductsDTO }

constructor TProductsDTO.Create;
begin
 inherited;
 FName := TNameDTO.Create;
 FDisplayInfo := TDisplayInfoDTO.Create;
end;

destructor TProductsDTO.Destroy;
begin
 FName.Free;
 FDisplayInfo.Free;
 GetOptionCategories.Free;
 inherited;
end;

function TProductsDTO.GetOptionCategories: TObjectList<TOptionCategoriesDTO>;
begin
 if not Assigned(FOptionCategories) then
 begin
   FOptionCategories := TObjectList<TOptionCategoriesDTO>.Create;
   FOptionCategories.AddRange(FOptionCategoriesArray);
 end;
 Result := FOptionCategories;
end;

{ TCourierDTO }

constructor TCourierDTO.Create;
begin
 inherited;
 FLocation := TLocationDTO_001.Create;
end;

destructor TCourierDTO.Destroy;
begin
 FLocation.Free;
 inherited;
end;

{ TClientDTO }

constructor TClientDTO.Create;
begin
 inherited;
 FLocation := TLocationDTO.Create;
 FDeliveryAddress := TDeliveryAddressDTO.Create;
end;

destructor TClientDTO.Destroy;
begin
 FLocation.Free;
 FDeliveryAddress.Free;
 inherited;
end;

{ TItemDTO }

constructor TItemDTO.Create;
begin
 inherited;
 FClient := TClientDTO.Create;
 FCourier := TCourierDTO.Create;
 FRestaurant := TRestaurantDTO.Create;
 FPaymentMethodText := TPaymentMethodTextDTO.Create;
end;

destructor TItemDTO.Destroy;
begin
 FClient.Free;
 FCourier.Free;
 FRestaurant.Free;
 FPaymentMethodText.Free;
 GetProducts.Free;
 inherited;
end;

function TItemDTO.GetProducts: TObjectList<TProductsDTO>;
begin
 if not Assigned(FProducts) then
 begin
   FProducts := TObjectList<TProductsDTO>.Create;
   FProducts.AddRange(FProductsArray);
 end;
 Result := FProducts;
end;

{ TRootDTO }

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

function TRootDTO.GetItems: TObjectList<TItemDTO>;
begin
 if not Assigned(FItems) then
 begin
   FItems := TObjectList<TItemDTO>.Create;
   FItems.AddRange(FItemsArray);
 end;
 Result := FItems;
end;

end.




Ayran biraz pahalı değil mi?   Exclamation

Örnek uygulama unit'leri:

Yardımınız için ne kadar teşekkür etsem azdır... Allah razı olsun... İşleriniz rast gitsin... Sağlıklı günler dilerim kardeşim çok sağol...
Cevapla


Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
  JSON DataSet Serialize for Unidac Halil Han BADEM 2 467 08-11-2023, Saat: 16:53
Son Yorum: Halil Han BADEM
  JSON Verilerini Veritabanına Kaydetmek kajmerantime 6 695 03-11-2023, Saat: 15:05
Son Yorum: kajmerantime
  JSon Format m_ekici 7 874 02-10-2023, Saat: 09:24
Son Yorum: yhackup
  RESTRequest Nesnesinde Body içinde JSON Gönderme Hk. pro_imaj 2 566 04-06-2023, Saat: 00:47
Son Yorum: pro_imaj
Exclamation delphi json binance uygulaması yardım fix1tr 7 1.578 31-03-2023, Saat: 10:48
Son Yorum: fix1tr



Konuyu Okuyanlar: 1 Ziyaretçi