AFNetworking posts JSON arrays as multiple single-entry dictionaries

前端 未结 4 1577
予麋鹿
予麋鹿 2020-12-19 13:26

I\'m having a similar issue to the one discussed here.

I\'m attempting to post JSON to a server.

Here\'s the Objective-C code that should work, but

4条回答
  •  有刺的猬
    2020-12-19 14:29

    I just dealt with the same issue and the only solution I could find was to create a dictionary out of the array. There must be a better way, this is pretty ugly...

        NSMutableDictionary *arrayDict = [[NSMutableDictionary alloc] init];
        int counter = 0;
        for (NSMutableDictionary *arrayItem in arrayToSend) {
            [arrayDict setObject:arrayItem forKey:[NSNumber numberWithInt:counter]];
            counter++;
        }
    

    Otherwise everything got flattened sort of. I use AFJSONRequestSerializer, but that doesn't seem to matter.

提交回复
热议问题