In my iPhone app, I am trying to use the JSON library (YAJL) to create a JSON string that looks like the following format:
{"user":
{"name":"Jon", "username":"jon22", "password":"passw@rd", "email":"jon22@example.com"}
}
But I can't figure out the YAJL methods to create this.
I have tried the following:
NSArray *params = [NSArray arrayWithObjects:@"Jon", @"jon22", @"passw@rd", @"jon22@gmail.com", nil];
NSArray *keys = [NSArray arrayWithObjects:@"name", @"username", @"password", @"email", nil];
NSDictionary *userDictionary = [NSDictionary dictionaryWithObjects:params forKeys:keys];
NSString *JSONString = [userDictionary yajl_JSONString];
However, the returned string is not wrapped in the outside "user". How can I use YAJL to create this json string? Does anyone have experience with this???
Many thanks, Brett