marcinmoskala
03/26/2018, 6:22 PMczyzby
03/26/2018, 6:23 PMczyzby
03/26/2018, 6:24 PMNews, they will lose all information except for the date. You have to add additional type field and deserialize into the correct type based on that field.marcinmoskala
03/26/2018, 6:25 PM// HACK: Serialization objects does not correspond correctly to real objects so we need to repack them all
override suspend fun getNewsData(): NewsData {
val str = httpGet(Endpoints.news)
val parsed = json.parse<NewsData>(str)
val articles = parsed.articles.map { Article(it.id, ArticleData(it.data.title, it.data.subtitle, it.data.imageUrl, it.data.url, it.data.occurrence), it.dateTime) }
val infos = parsed.infos.map { Info(it.id, InfoData(it.data.title, it.data.imageUrl, it.data.description, it.data.sources, it.data.url, it.data.author, it.data.authorUrl), it.dateTime, it.accepted) }
val puzzlers = parsed.puzzlers.map { Puzzler(it.id, PuzzlerData(it.data.title, it.data.level, it.data.question, it.data.answers, it.data.correctAnswer, it.data.explanation, it.data.author, it.data.authorUrl), it.dateTime, it.accepted) }
val newsData = NewsData(articles, infos, puzzlers)
return newsData
}czyzby
03/26/2018, 6:25 PMval parsed = json.parse<NewsData>(str)marcinmoskala
03/26/2018, 6:26 PMczyzby
03/26/2018, 6:27 PMmarcinmoskala
03/26/2018, 6:27 PMgetNewsData returns correct lists and all objects there are created in Kotlin/JS (as you can see above)marcinmoskala
03/26/2018, 6:28 PMczyzby
03/26/2018, 6:29 PM@Serializable?bashor
03/26/2018, 6:34 PMmarcinmoskala
03/26/2018, 6:40 PMmarcinmoskala
03/26/2018, 6:41 PMbashor
03/26/2018, 6:42 PMmarcinmoskala
03/26/2018, 6:42 PMnews instead of newsData in showList function on NewsComponentczyzby
03/26/2018, 6:42 PM@Serializable is causing the issue.czyzby
03/26/2018, 6:43 PMkotlinx-serialization in a toy project, this feels like a major bug.bashor
03/26/2018, 6:50 PMmarcinmoskala
03/26/2018, 6:54 PMbashor
03/26/2018, 6:57 PMbashor
03/26/2018, 6:58 PMmarcinmoskala
03/26/2018, 7:42 PMmarcinmoskala
03/26/2018, 7:45 PMmarcinmoskala
03/26/2018, 7:50 PMbashor
03/26/2018, 7:53 PMbashor
03/26/2018, 7:54 PMmarcinmoskala
03/26/2018, 8:43 PMcommon or in common-client then I must clean it, because just run doesn't use new code.sandwwraith
03/26/2018, 10:07 PMkotlin.js.JSON with kotlinx.serialization.json.JSON? The former is known to produce “not fair” kotlin objectsmarcinmoskala
03/26/2018, 10:12 PM