objective-c icon indicating copy to clipboard operation
objective-c copied to clipboard

PNJSONSerialization replacing NSNull characters during serialization prevents proper deserialization

Open AdamPro13 opened this issue 11 years ago • 1 comments

I've been having an issue when I try to send a PNMessage with a message that contains an NSNull value.

I see when I try to send a PNMessage, you're serializing the message using the method PNJSONSerialization +stringFromJSONObject:. This method serializes the object, then starting on line 196 you have

// Replace null value has been passed or not (serialized [NSNull null] value)
if ([JSONString respondsToSelector:@selector(stringByReplacingOccurrencesOfString:withString:)]) {

    JSONString = [JSONString stringByReplacingOccurrencesOfString:@":null" withString:@":\"null\""];
}

The problem with this is it's preventing me from properly deserializing the message that is returned in by the PNDelegate method pubNubClient:didReceiveMessage:. Those original NSNull objects are being deserialized to NSStrings with value null.

I tried removing those lines of code and the message is sending and being received as expected now.

AdamPro13 avatar Apr 17 '15 18:04 AdamPro13

Hi @AdamPro13

This is not really solution for your issue. Changes should be done on corresponding step - deserialisation. We will include proper fix in future release.

Best regards, Sergey

parfeon avatar Apr 24 '15 14:04 parfeon