需要動態生成json字符串然後發送到服務器,不知道應該怎麼實現?
使用了NSJSONSerialization
。
下面就是字符串:
{
"surveyid": "Survey1",
"responsetime": "dd/mm/yyyy hh:mm:ss",
"location": null,
"surveyresponses": [
{
"questionid": "111",
"responses": [
{
"response": "Good",
"optionid": 1,
"language": "en"
}
]
},
{
"questionid": "112",
"responses": [
{
"response": "bad",
"optionid": 2,
"language": "en"
}
]
}
]
}
創建一個string.json,請高手幫忙啊。謝謝
將Json轉化為JsonString,將其放在NSData裡面,通過ASIDataFormRequest setPostValue: forKey:,發送到服務器即可