1

I am really in need to fix this issue, I am posting an array with few parameters usingASIHTTPRequest by creating the request:

{
categories={
    attributes=({
        id=1;values=();
    });categories=({
        id=9;values=({
            id=28;
        });
    });
};description=dfsvdsfs;id=0;localid=1;originalid=0;remarks="";sections=();title=Hhhh;} 

but when I post this in format of json on server end this gets changed and add \n in between the array :

{
"sections": "(\n)",
"categories": "{\n 
 attributes = (\n {\n id = 1;\n 
 values = (\n );\n }\n );\n 
 categories = (\n {\n id = 9;\n 
 values = (\n {\n id = 28;\n }\n );\n }\n 
);\n}",
 "id": "0",
"originalid": "0",
"localid": "1",
"title": "Hhhh",
"description": "dfsvdsfs",
"remarks": ""
}

Please suggest me what i should need to do ?

I have tried to remove \n using :

[value stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];

4

1 回答 1

1

试试这个方法,

NSData *jsonData = [NSJSONSerialization dataWithJSONObject:objcts
          options:NSJSONWritingPrettyPrinted error:&error];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

其中 objcts= 你的数组

于 2013-10-08T12:55:52.903 回答