I'm developing an iOS app which make use of a web service written in java. The app make a POST request to this web server sending an NSData object, created from a JSON, which is for example:
<7b22636c 69656e74 223a7b22 656e7669 726f6e6d 656e7422 3a227361 6e64626f 78222c22 70726f64 7563745f 6e616d65 223a2250 61795061 6c20694f 53205344 4b222c22 70617970 616c5f73 646b5f76 65727369 6f6e223a 22322e32 2e31222c 22706c61 74666f72 6d223a22 694f5322 7d2c2272 6573706f 6e73655f 74797065 223a2270 61796d65 6e74222c 22726573 706f6e73 65223a7b 22696422 3a225041 592d3233 44393230 32375545 36383337 3034304b 51434337 5859222c 22737461 7465223a 22617070 726f7665 64222c22 63726561 74655f74 696d6522 3a223230 31342d30 392d3031 5430383a 33353a34 335a222c 22696e74 656e7422 3a227361 6c65227d 7d>
so in my servlet I do
String req = request.getParameter("data");
but obviously when I try to print it I get the bytes above.
How can I convert such data into the initial JSON?
EDIT 1: I send an NSData in this way
NSData *confirmation = [NSJSONSerialization dataWithJSONObject:completedPayment.confirmation
options:0
error:nil];
NSURL *url = [NSURL URLWithString:@"MY_WS"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *messageBody = [NSString stringWithFormat:@"data=%@", confirmation];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[messageBody dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
I think I cannot send the JSON string directly...