Code Monkey home page Code Monkey logo

Comments (2)

dsrees avatar dsrees commented on August 15, 2024

You can implement your own decoder (see Defaults.swift) but the client is expecting that decoder will return [Any] which will be parsed into a Message. If you don't decode the Data into the correct format then you wont receive any messages to your channels

guard
      let data = rawMessage.data(using: String.Encoding.utf8),
      let json = decode(data) as? [Any?],
      let message = Message(json: json)
      else {
        self.logItems("receive: Unable to parse JSON: \(rawMessage)")
        return }

Do your models convert Data to MyModel and you're wanting to convert Message.payload into MyModel without using JSON serialization?

from swiftphoenixclient.

ream88 avatar ream88 commented on August 15, 2024

Do your models convert Data to MyModel and you're wanting to convert Message.payload into MyModel without using JSON serialization?

Basically yes, I already have my decoding logic written, and it's accepting Data and converts it to MyModel. Serializing [Any] back to JSON to then convert it to MyModel just feels wrong, therefore I think some kind of low-level API to access the raw Data would be awesome.

from swiftphoenixclient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.