Reputation: 6606
I have an iOS Application which makes a POST request to a server. In the body I have to add metadata in JSON format.
The JSON I have to send is this:
{
"snippet": {
"title": {VIDEO TITLE},
"description": {VIDEO DESCRIPTION},
"tags": [{TAGS LIST}],
"categoryId": {YOUTUBE CATEGORY ID}
},
"status": {
"privacyStatus": {
"public", "unlisted" OR "private"
}
}
}
I have tried creating the JSON in a NSDictionary like this, but it doesn't seem to work:
NSDictionary *metadat = @{@"snippet" : @"{",
@"title" : @"test_name",
@"description": @"test_desc",
@"tags": @"[test]",
@"categoryId" : @"{1111}",
@"}",
@"status" : @"{",
@"privacyStatus" : @"{",
@"public",
@"}",
@"}",
@"}"};
What am I doing wrong? I have followed the structure of the JSON format.
Thank you for your time, Dan.
Upvotes: 0
Views: 75
Reputation: 69459
You don't add the {
to the dictionary, but just add another NSDictionary.
But the example JSON is not really valid JSON, the privacyStatus
seems a bit weird.
Something like:
NSDictionary *metadat = @{@"snippet" : @{
@"title" : @"test_name",
@"description": @"test_desc",
@"tags": @[@"test"],
@"categoryId" : @"{1111}",
},
@"status" : @{
@"privacyStatus" : @"public"
},
};
Upvotes: 3