ios - Can I serialize negative integer by NSJSONSerialization? -


i can't serialize negative integer nsjsonserialization.

objective-c :

nsmutabledictionary *senddata = [nsmutabledictionary dictionarywithobjectsandkeys:                            @480, @"width",                           @800, @"height"                           @-10, @"value1",                            @10, @"value2", nil];   nserror *error = nil; nsdata *datajson = [nsjsonserialization datawithjsonobject:senddata options:0 error:&error]; nslog(@"senddata\n %@ \n\n", [senddata description]); 

log

senddata{             width = 480;      // int            height = 800;     // int            value1 = "-10";   // string. not integer!!            value2 = 10;      // int           } 

how can serialize negative integer?

you're correct, , everything's fine. that's dictionary -description being misleading.

nsmutabledictionary *senddata = [nsmutabledictionary dictionarywithobjectsandkeys:                                      [nsnumber numberwithint:-10], @"value1",                                      [nsnumber numberwithint:10], @"value2", nil];       nserror *error = nil;     nsdata *datajson = [nsjsonserialization datawithjsonobject:senddata options:0 error:&error];     nslog(@"senddata\n %@ \n\n", [senddata objectforkey:@"value1"]); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -