Ich bekomme "\ n" in einer Websocket/SignalR Antwort und ich kann nicht herausfinden, warum. Ich habe versucht, meinen Datentyp für das Antwortobjekt zu ändern, es als JSON zu analysieren, aber das "\ n" immer noch nicht loszuwerden." n" in Websocket/SignalR-Antwort erhalten?
Wie kann ich dieses "\ n" entfernen und wie jedes andere JSON-Objekt/Antwort behandeln?
-Code als Referenz:
-(void)SignalR{
WebServices *services = [[WebServices alloc] init];
SRHubConnection *hubConnection = [SRHubConnection connectionWithURLString:@"xxx"];
SRHubProxy *proxy = [hubConnection createHubProxy:@"xxx"];
[services callGetSRAlertGroupNames:^(NSMutableArray *alertGroupNameArray){
NSLog(@"SR ALERT GROUP NAMES: %@", alertGroupNameArray);
[services callGetSRNotificationGroupNames:^(NSMutableArray *notificationGroupNameArray) {
NSLog(@"SR NOTIFICATION GROUP NAMES: %@", notificationGroupNameArray);
NSArray *combinedArray=[alertGroupNameArray arrayByAddingObjectsFromArray:notificationGroupNameArray];
// Register for connection lifecycle events
[hubConnection setStarted:^{
NSLog(@"Connection Started");
for (NSString *groupName in combinedArray){
[proxy invoke:@"Subscribe" withArgs:@[groupName] completionHandler:nil];
}
}];
[hubConnection setReceived:^(NSString *data) {
NSLog(@"CONNECTION RECIEVED - %@",data);
}];
[hubConnection setConnectionSlow:^{
NSLog(@"Connection Slow");
}];
[hubConnection setReconnecting:^{
NSLog(@"Connection Reconnecting");
}];
[hubConnection setReconnected:^{
NSLog(@"Connection Reconnected");
}];
[hubConnection setClosed:^{
NSLog(@"Connection Closed");
}];
[hubConnection setError:^(NSError *error) {
NSLog(@"Connection Error %@",error);
}];
[hubConnection start];
}];
}];
}
Abgemeldet Antwort Beispiel:
CONNECTION RECIEVED - {
A = (
"{
\n \"NotificationType\": 1,
\n \"TelemetryDetails\": {
\n \"serialNumber\": \"xxx\",
\n \"name\": \"sf-top\",
\n \"statusId\": 2,
\n \"buildVersion\": \"xxx\",
\n \"securityModeId\": 2,
\n \"IP\": \"xxx\",
\n \"priority\": 1,
\n \"bandwidthUpload\": 0.00,
\n \"bandwidthDownload\": 0.00,
\n \"bandwidthInternal\": null,
\n \"totalBandwidthUpload\": 3107397.00,
\n \"totalBandwidthDownload\": 8078656.00,
\n \"totalBandwidthInternal\": null,
\n \"usage\": \"8078656/3107397\",
\n \"lastUpdateTime\": \"2017-03-02T16:27:57.1736937Z\",
\n \"buildVersionUpdatingInProgress\": false,
\n \"transportType\": 2,
Aus meiner Erfahrung ist das keine normale Antwort mit Signal R. Es gibt eine Chance, dass Ihr Backend eingerichtet ist, um Ihnen die Informationen zu senden - haben Sie das überprüft, um das auszuschließen? – Kiley