无法使用alamofire库解析swift ios中的json

时间:2017-04-14 10:00:21

标签: ios swift3 alamofire

我无法使用xcode中的alamofire库解析下面提到的响应。请提供任何可以帮助我解决问题的建议或代码。

  {
      "ResponseObject": {
        "comapny": [
          {
             "cName": "Makkhan Kitchens",
            "cAddress": null,
            "cPhoneMobile": "+91-9261600650",
            "cPhoneOffice": "+91-294-6500650",
            "cEmail": "info@makkhankitchens.com",
            "cCompanyPolicies": "<p style=\"font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;\"><strong style=\"font-family:Verdana, Geneva, sans-serif;font-size:12px;\">Return Policy&nbsp;</strong><strong></strong></p><p>We want our customers to be happy with every single purchase from our store!!<br /><br />We offer a simple, clear cut return policy to our customers in order to make returns easy for you. As our products are perishable, all food sales are&nbsp;final.<br /><br />Makkhan Kitchen will be happy to replace any item(s) in the unlikely event that they might be damaged or spoiled during transit. To make sure that&nbsp;you are satisfied with the product you receive, please inspect the contents as soon as your order arrives.</p><p><strong>Cancellation Policy</strong><br /><br />The online order once placed cannot be modified or cancelled either through the website or offline by calling the restaurant or at Call Center.<br />However you can get an update on the status of the order by calling the restaurant directly or at Call Center.</p><p>For any query or information you can&nbsp;<strong>Call Us</strong>&nbsp;on<strong>&nbsp;029426500650</strong>.</p><p style=\"font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;\"></p>",
            "cWebsite": "http://www.makkhankitchens.com/",
            "Disclaimer": "<p data-mce-style=\"text-align: left;\" style=\"font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;\"><strong style=\"font-family:Verdana, Geneva, sans-serif;font-size:12px;\">Terms Of Use</strong></p><p data-mce-style=\"text-align: left;\" style=\"font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;\"><span style=\"font-family:Verdana, Geneva, sans-serif;font-size:12px;\">Makkhan Kitchen grants you permission to view this website and to print individual pages from this website for your own personal, non-commercial use, provided that you agree to and accept without modification of notices, terms, and conditions set forth in this agreement. You may not modify, copy (except as set forth in the preceding sentence), distribute, transmit, display, perform, reproduce, publish, license, create derivative works from, transfer, or sell any information, material, software, products or services from this website.</span><strong></strong></p><p>Your use of this website constitutes your agreement and acceptance without modification of the notices, terms and conditions set forth herein.&nbsp;</p><p>In addition, as a condition of your use of this website, you represent and warrant to Makkhan Kitchen that you will not use this website for any purpose that is unlawful, immoral, or prohibited by these terms, conditions, and notices. If you do not agree and accept without modification of the notices, terms and conditions set forth herein, do not use this website. Other than this agreement, Makkhan Kitchen will not enter into any agreement with you or obligation to you through this website, and no attempt to create such an agreement or obligation will be effective.</p><p><strong>Delivery Policy&nbsp;</strong><br /><br />The Delivery Time for Makkhan Kitchen will take atleast 60 Minutes after you place your order.&nbsp;Minimum Order Amount is Rs. 400/- &nbsp;for Home Delivery, Delivery charges will be applied if order Amount is between Rs. 400-600, but above Rs.600&nbsp;order amount there will be no delivery charges. Bulk orders shall not be valid for service guarantee of 60 minutes.&nbsp;</p><p>Delivery time may vary subject to distance, traffic, festive occasions, first barrier point (security guard/reception etc.) or any other unavoidable conditions.&nbsp;</p><p>Makkhan Kitchen reserves the right to withdraw the service guarantee without prior intimation.&nbsp;<br /><br /><strong>Coupon Policy</strong>&nbsp;</p><p>Terms and Conditions for all coupons including printed, mobile and email coupons.<br /><br />* Coupons cannot be clubbed with any other offer / scheme.<br />* Please announce the coupon and coupon code to the order taker while placing the order.<br />* All prices are exclusive of taxes.<br />* Only one coupon is valid per order.<br />* All coupons have limited validity.</p><p style=\"font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;\"></p>",
            "nFutureOrderDays": 2,
            "nMinOrderAmt": 600.00,
            "nMinOrderPlacingAmt": 400.00,
            "nMaxOrderPlacingAmt": 2500.00,
            "nMaxOrderAmtForWarning": 2000.0,
            "cMaxOrderAmtForWarningMsg": "Your order amount exceeded rupees #nMaxOrderAmtForWarning. It will require 50% advance amount to start preparing this order.Please contact 0294-6500650",
            "nMaxOrderQty": 25,
            "cCurrencyCode": "INR",
            "bImagesVisible": true,
            "nOrderFillMode": 2,
            "bIsDiscountAfterTax": true,
            "nOrderFillModeDefault": 2,
            "cBannerImagePath": "http://www.makkhankitchens.com/Images/StoreImages/e48ac928-b259-441f-b633-9c3588f956d5.jpg"
          }
        ]
      },
       "ResponseCode": 202
    }

我试过这个方法来解析json。但它只是解析响应码而不是响应对象。

func fetchData()
    {
        let api = APIManager()
        let response = api.getReturnPolicy(){(userJson)-> Void in

        if userJson != nil
        {

            let coun = userJson.count

            print(coun)
            print(userJson["ResponseCode"])
            let companyArray = userJson["ResponseObject"]["comapny"].arrayObject
            let companyDic = companyArray?[0] as! NSDictionary
            print("\(companyDic)")
            let disclaimerString = companyDic.value(forKey: "Disclaimer") as? String
            print("\(disclaimerString)")

        }
    }
    print("resposnse ", response)
}

0 个答案:

没有答案