Nested JSON parse in Swift

Viewed 78

How to change this to swift struct form, if i want all datas from all loops?

Means from commonsOfList I want storid,id,isActive,keyname,status,value like all data I want from all loops

    Optional({ 
    storeName = DocStore;
    commonsOfList =     (
                {
            storeId = 0;
            id = 1;
            isActive = 0;
            keyname = Contacts;
            status = 0;
            value = store;
        },
                {
            storeId = 0;
            id = 2;
            .
        .
    .   },
    .
    .   
    .

    );
 currentDate = "2018/11/05";
    grandTotals =     (
                {
            storeId = 0;
            commonId = 0;
            consentId = 0;
            Id = 0;
            grandTotal = 300;
             },
                {
            storeId = 0;
            commonId = 0;
            consentId = 0;
            Id = 0;
            grandTotal = 5500;
            }
    .   
    .
    {
    .   
    .
 }
    );
staffList=     (
                {
            accountExist = 0;
            adharId = 123456789012;
            admnId = 0;
            advanceAmount = 0;
            age = 18;
            storeId = 0;
    mob.No = 9876543200
        }
    .
    .
        {

    .
});
 procedureCommonId =     (
                {
            storeId = 0;
            commonId = 1;
            consentId = 0;
            Id = 0;
            paymentid = 0;
            InvoiceStatus = 0;
            proPlannDate = "25/10/2018";
            Status = 0;
            taxId = 0;
            totalCost = 0;
            totalDisCost = 0;
            PlanId = 0;
        },
             {
    .
    .
});
 storeList = (
   {
    :
    :
    :
   });

**

   struct list: Decodable {

  let name: String
  .
  .
  .

enum CodingKeys: String, CodingKey {

    case name = "name"
     .
     .
     .

}
}

**

if you know this please respond thank you

Because the mapping between JSON keys and container properties and the parsing syntax are tightly coupled, we are going to examine the details for both, at the same time.

0 Answers
Related