framework. Hi I'm using json-framework.
How to get sorted string when using JSONRepresentation method? Here is my code:
NSMutableDictionary *tUserIDParam = [NSMutableDictionary dictionary];
[tUserIDParam setObject:@"UserID" forKey:@"@key"];
[tUserIDParam setObject:@"string" forKey:@"@type"];
[tUserIDParam setObject:@"mark" forKey:@"#text"];
NSMutableDictionary *tPasswordParam = [NSMutableDictionary dictionary];
[tPasswordParam setObject:@"Password" forKey:@"@key"];
[tPasswordParam setObject:@"string" forKey:@"@type"];
[tPasswordParam setObject:@"123456" forKey:@"#text"];
NSArray *tParams = [NSArray arrayWithObjects:tUserIDParam,tPasswordParam, nil];
NSDictionary *tParam = [NSDictionary dictionaryWithObject:tParams forKey:@"param"];
NSMutableDictionary *tRequests = [NSMutableDictionary dictionary];
[tRequests setObject:[NSNull null] forKey:@"key"];
[tRequests setObject:[NSNull null] forKey:@"basic"];
[tRequests setObject:tParam forKey:@"conditions"];
NSDictionary *tRequest = [NSDictionary dictionaryWithObject:tRequests forKey:@"request"];
NSString *tJSONStrFromDict = [tRequest JSONRepresentation];
I want to get JSON string like:
{"request":{"key":null,"basic":null,"conditions":{"param":[{"@key":"UserID","@type":"string","#text":"mark"},{"@key":"Password","@type":"string","#text":"123456"}]}}}
But I got this string from above code:
{"request":{"basic":null,"conditions": {"param":[{"#text":"mark","@key":"UserID","@type":"string"},{"#text":"123456","@key":"Password","@type":"string"}]},"key":null}}
I try to use SBJSONWriter sortKeys property,it does not work...
Have any way to solve my problem?
Thanks!