Я пытаюсь сгенерировать параметр для запроса JSON POST. Вот чего я хочу достичь:
{
"Associate_Name": "SAURABH K WATT",
"Associate_Code": "DT1006",
"Transaction_No": "6",
"TRANSACTION_MODE": "2",
"COMPANY_NO": "cogni",
"LOCATION_NO": "NOIDA",
"REPORTING_DATE": "2019-07-09",
"SERVER_DATE": "2019-07-11",
"ItemDtail": [
{
"LI_NO": "1",
"CUSTOMER_ID": "C103",
"PROJECT_ID": "IMSGTPL0052",
"Activity_Id": "DEVELOPMEN",
"ACTIVITY": "DEVELOPMEN",
"ACTIVITY_DETAILS": "test",
"TOTAL_HOURS": "1.30",
"PERCENTAGE": "16.25",
"STATUS": "2",
"REMARKS1": "",
"REMARKS2": "",
"REMARKS3": "",
"user_id": "62",
"Doc_Status": "F",
"ConvertedTime": "1.30",
"CaseId": "0"
},
{
"LI_NO": "2",
"CUSTOMER_ID": "C103",
"PROJECT_ID": "PROJ1029",
"Activity_Id": "DEV2",
"ACTIVITY": "DEV2",
"ACTIVITY_DETAILS": "sat",
"TOTAL_HOURS": "6.30",
"PERCENTAGE": "78.75",
"STATUS": "1",
"REMARKS1": "",
"REMARKS2": "",
"REMARKS3": "",
"user_id": "62",
"Doc_Status": "F",
"ConvertedTime": "6.30",
"CaseId": "0"
}
]
}
Я пробовал до сих пор так:
let param : [String:Any] = [
"Associate_Name": "SAURABH K WATT",
"Associate_Code": "DT1006",
"Transaction_No": "13",
"TRANSACTION_MODE": "1",
"COMPANY_NO": "cogni",
"LOCATION_NO": "NOIDA",
"REPORTING_DATE": "2019-07-05",
"SERVER_DATE": "2019-07-11",
"ItemDtail": [
[
"LI_NO": "1",
"CUSTOMER_ID": "C103",
"PROJECT_ID": "IMSGTPL0052",
"Activity_Id": "DEVELOPMEN",
"ACTIVITY": "DEVELOPMEN",
"ACTIVITY_DETAILS": "test",
"TOTAL_HOURS": "1.30",
"PERCENTAGE": "16.25",
"STATUS": "2",
"REMARKS1": "",
"REMARKS2": "",
"REMARKS3": "",
"user_id": "62",
"Doc_Status": "F",
"ConvertedTime": "1.30",
"CaseId": "0"
]
]
]
, но изсохраняя таким образом, я получаю неправильную последовательность JSON, моя последняя печать JSON выглядит так:
JSON string =
{
"Transaction_No" : "13",
"TRANSACTION_MODE" : "1",
"COMPANY_NO" : "cogni",
"SERVER_DATE" : "2019-07-11",
"Associate_Code" : "DT1006",
"ItemDtail" : [
{
"TOTAL_HOURS" : "1.30",
"ACTIVITY" : "DEVELOPMEN",
"ConvertedTime" : "1.30",
"CUSTOMER_ID" : "C103",
"Activity_Id" : "DEVELOPMEN",
"PERCENTAGE" : "16.25",
"REMARKS1" : "",
"REMARKS3" : "",
"ACTIVITY_DETAILS" : "test",
"user_id" : "62",
"CaseId" : "0",
"STATUS" : "2",
"LI_NO" : "1",
"PROJECT_ID" : "IMSGTPL0052",
"Doc_Status" : "F",
"REMARKS2" : ""
}
],
"REPORTING_DATE" : "2019-07-05",
"LOCATION_NO" : "NOIDA",
"Associate_Name" : "SAURABH K WATT"
}
Это неправильно.Пожалуйста, помогите, я искал везде, но не нашел никакого решения, я застрял в последние 3 дня на этом.