2016-10-01 54 views
0

我必須發送非常大的JSON文件。在製作該JSON文件的過程中,xcode會給出編譯時錯誤:表達式太複雜,無法實時解析。swift - 表達式太複雜

我已經嘗試過使用SwiftyJson。即使我將大字符串分成較小的字符串,由於「+」運算符的數量很多,它也會給我帶來同樣的錯誤。有沒有人有這個解決方案?

這是代碼:`等的JSONObject:JSON = [

 "salesAgentID": SalesAgentID, 

     "customerInformation": [ 

      "customerName": CustomerInfo[1], 
      "company": CustomerInfo[2], 
      "address" : CustomerInfo[3], 
      "city" : CustomerInfo[4], 
      "postalCode" : CustomerInfo[5], 
      "mobile" : CustomerInfo[6], 
      "phone" : CustomerInfo[7], 
      "email" : CustomerInfo[8], 
      "deliveryAddress" : CustomerInfo[9] 


     ], 


     "measurements": [ 

      "point": String(uiSliderArray[0]), 
      "halfBody": String(uiSliderArray[1]), 
      "fullBody": String(uiSliderArray[2]), 
      "kneeLength" : String(uiSliderArray[3]), 
      "shortLength" : String(uiSliderArray[4]), 
      "longLength" : String(uiSliderArray[5]), 
      "chesy": String(uiSliderArray[6]), 
      "bust": String(uiSliderArray[7]), 
      "waist": String(uiSliderArray[8]), 
      "smallHip" : String(uiSliderArray[9]), 
      "hips" : String(uiSliderArray[10]), 
      "shoulder" : String(uiSliderArray[11]), 
      "backCarrue": String(uiSliderArray[12]), 
      "frontCarrue": String(uiSliderArray[13]), 
      "backNeck": String(uiSliderArray[14]), 
      "frontNeck" : String(uiSliderArray[15]), 
      "widthOfNeckline" : String(uiSliderArray[16]), 
      "sleevesFull" : String(uiSliderArray[17]), 
      "sleevesThreeQuarter": String(uiSliderArray[18]), 
      "elbow": String(uiSliderArray[19]), 
      "sleevesHalf": String(uiSliderArray[20]), 
      "bicep" : String(uiSliderArray[21]), 
      "empire" : String(uiSliderArray[22]), 
      "armhole" : String(uiSliderArray[23]), 
      "lowerLength": String(uiSliderArray[24]), 
      "lowerWaist" : String(uiSliderArray[25]), 
      "thigh" : String(uiSliderArray[26]), 
      "kneeLength2" : String(uiSliderArray[27]), 
      "calf": String(uiSliderArray[28]), 
      "ankle": String(uiSliderArray[29]) 
         ], 

     "Order": [ 

      "agentID": SalesAgentID, 
      "orderStatus": orderStatus, 
      "reference": referenceTextField.text, 
      "advancePaid" : advancePaidTextField.text, 
      "totalPayment" : totalPaymentTextField.text, 
      "choli" : ArrayforDressTypeSelection[0][0], 
      "shirt" : ArrayforDressTypeSelection[0][1], 
      "angrakha" :ArrayforDressTypeSelection[0][2], 
      "jacket": ArrayforDressTypeSelection[0][3], 
      "longSleeve" : ArrayforDressTypeSelection[1][0], 
      "threeQuarterSleeve" : ArrayforDressTypeSelection[1][1], 
      "elbowSleeve" : ArrayforDressTypeSelection[1][2], 
      "sleeveless" : ArrayforDressTypeSelection[1][3], 
      "saree" : ArrayforDressTypeSelection[2][0], 
      "gown" : ArrayforDressTypeSelection[3][0], 
      "cigarettePant" : ArrayforDressTypeSelection[4][0], 
      "bootcutPant" : ArrayforDressTypeSelection[4][1], 
      "izaar" : ArrayforDressTypeSelection[4][2], 
      "lehengaWithTrail" : ArrayforDressTypeSelection[4][3], 
      "lehengaWithoutTrail" : ArrayforDressTypeSelection[4][4], 
      "sharara" : ArrayforDressTypeSelection[4][5], 
      "gharara" : ArrayforDressTypeSelection[4][6], 
      "dhotiShalwar" : ArrayforDressTypeSelection[4][7], 
      "shalwar" : ArrayforDressTypeSelection[4][8], 
      "flaredPant" : ArrayforDressTypeSelection[4][9] 



     ] 


    ]` 
+0

可能的重複http://stackoverflow.com/questions/29707622/bizarre-swift-compiler-error-expression-too-complex-on-a-string-concatenation/29931329#29931329。將大字符串連接分解爲更簡短的語句,並強烈鍵入每個「+」操作的輸入和輸出可能會有所幫助。 – hotpaw2

回答

0

我建議創建類的測量,命令等。然後使類功能是從該類對象創建JSON對象(或字典)和然後團結他們。