ios - objective-c json serialization -


i need create post request , in it's body need put json. template json file follows:

{"key" : [{...}, {...}, {...} ..... ]} 

what i've tried doing this:

@{@"key" : @[@{...}, @{...} ... ]}; 

the issue have puts round brackets around nsarray. output:

{key = ({...}, {...}, ..... )} 

snippet code(after i've created nsdictionary)

    nserror *error;     nsdata *jsondata = [nsjsonserialization datawithjsonobject:mydictionary                                                        options:nsjsonwritingprettyprinted                                                          error:&error];     [request sethttpbody:jsondata]; 

is there way me make nsarray have [ ] instead of ( )?

nslog uses {} printing nsdictionary , () printing nsarray contents. has nothing json. json data structure created , encoded correctly. verify this:

nslog(@"%@", [[nsstring alloc] initwithdata:jsondata encoding:nsutf8stringencoding]); 

and see actual json printed.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -