PayloadCoder

public class PayloadCoder

PayloadCoder provides utility methods to encode and decode communication events from and to JSON.

  • Decodes a communication event from its JSON representation.

    Note

    The JSON decoding is based on the Codable protocol from the Swift standard library. Please make sure to implement it in all CommunicationEvent and CoatyObject classes.

    Declaration

    Swift

    public static func decode<T>(_ jsonString: String) -> T? where T : Decodable, T : Encodable
  • Encodes a communication event to its JSON representation.

    Note

    The JSON encoding is based on the Codable protocol from the Swift standard library. Please make sure to implement it in all CommunicationEvent and CoatyObject classes.

    Declaration

    Swift

    public static func encode<T>(_ event: T) -> String where T : Decodable, T : Encodable