I have to generate a json string dynamically and need to send to the server. Is any body know how to do it using NSJSONSerialization
. Below is my string
{
"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"
}
]
}
]
}
How can I create a string.json?
i totally agree with @Apurv, actually @Paras Joshi give the actual answer to your question...(how to send)
NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
[dict setValue:@"Survey1" forKey:@"surveyid"];
[dict setValue:@"responsetime" forKey:@"dd/mm/yyyy hh:mm:ss"];
.
.
.
and then an array forKey @"surveyresponses"
... in it again create a dictionary...bla..bla
Please make it clear first what you exactly want... How to send a JSON string / how to generate a JSON value.
learn to accept the answers as well as analyse the answers perfectly, and make your questions clear.