diff options
Diffstat (limited to 'SmartDeviceLink/SDLV1ProtocolMessage.m')
-rw-r--r-- | SmartDeviceLink/SDLV1ProtocolMessage.m | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/SmartDeviceLink/SDLV1ProtocolMessage.m b/SmartDeviceLink/SDLV1ProtocolMessage.m index 736dd0b13..8083b198f 100644 --- a/SmartDeviceLink/SDLV1ProtocolMessage.m +++ b/SmartDeviceLink/SDLV1ProtocolMessage.m @@ -2,10 +2,9 @@ // #import "SDLV1ProtocolMessage.h" -#import "SDLJsonDecoder.h" +#import "SDLDebugTool.h" #import "SDLProtocolHeader.h" - @implementation SDLV1ProtocolMessage - (instancetype)initWithHeader:(SDLProtocolHeader *)header andPayload:(NSData *)payload { @@ -17,7 +16,17 @@ } - (NSDictionary *)rpcDictionary { - NSDictionary *rpcMessageAsDictionary = [[SDLJsonDecoder instance] decode:self.payload]; + if (self.payload.length == 0) { + return nil; + } + + NSError *error = nil; + NSDictionary * rpcMessageAsDictionary = [NSJSONSerialization JSONObjectWithData:self.payload options:kNilOptions error:&error]; + if (error != nil) { + [SDLDebugTool logInfo:[NSString stringWithFormat:@"Error decoding JSON data: %@", error] withType:SDLDebugType_Protocol]; + return nil; + } + return rpcMessageAsDictionary; } |