https://kotlinlang.org logo
Title
h

Hexa

09/29/2018, 5:40 PM
@karelpeeters thanks my main problem is that
fun processIncomingMessages(incomingMessage: List<IncomingMessage>)
is actually a function that thats a list of
SomeOtherType
but not
IncomingMessage
.
SomeOtherType
is just a json message, so I need to process each json message and wrap them in a IncomingMessage class. So it's actually look more like this this ( I try to use jacksonmapper library)
// example incoming messages:
    //  {"message":"message1", phoneType":"iPhoneX", "test1"},
    //  {"message":"message1", phoneType":"Samsung1", "test2"}

    fun processIncomingMessages(incomingMessage: List<SomeType>): Map<MessageIndex, List<Message>>{


      //how do  I need to process each incoming json messsage and wrap them in IncomingMessage class?
        return incomingMessage.forEach {

                          val eventObj = jacksonObjectMapper().readValue(String(it.data.array()), IncomingMessage::class.java)

        }
k

karelpeeters

09/29/2018, 6:01 PM
That doesn't look like valid JSON to me?
And I'm only talking about the
MessageIndex
-constructor making network calls, where the actual data comes from at first isn't relevant.
h

Hexa

09/29/2018, 6:24 PM
let me clarify.
{"message":"message1", phoneType":"iPhoneX", "test1"}
is one example of a message that will get sent. Since there will a lot of these message there will be a list of them that that will get sent hence they are in a
incomingMessage: List<SomeType>)
. Now it gets a bit tricky to achieve my original goal because I think I need to loop thru each json message first and wrap them to IncomingMessage class
k

karelpeeters

09/29/2018, 6:24 PM
{"message":"message1", phoneType":"iPhoneX", "test1"}
is not valid JSON though.
h

Hexa

09/29/2018, 6:35 PM
{"message":"message1", phoneType":"iPhoneX", "someOtherProperty": "test1"}
<----- ah sorry it should be like this so that it can be wrap easily in IncomingMessage class