Skip to content

PNJSONSerialization replacing NSNull characters during serialization prevents proper deserialization #87

@AdamPro13

Description

@AdamPro13

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions