This message was deleted.
# server
s
This message was deleted.
d
I would think it would be closer to the following…
Copy code
data class News (
    val error: String, // Boolean?
    val category: String,
    val type: String, // Should this be an enum
    val setup: String,
    val delivery: String,
    val flags: Flags,
    val id: String, // UInt?
    val safe: String, // Boolean?
    val lang: String
)

data class Flags (
    // These could be Boolean
    val nsfw: String,
    val religious: String,
    val political: String,
    val racist: String,
    val sexist: String,
    val explicit: String
)
…making the fields optional where needed.
👍 1
d
Thanks David I will try it out now!
I am getting this error:
Copy code
Caused by: nl.adaptivity.xmlutil.serialization.UnknownXmlFieldException: Could not find a field for name News/error
  candidates: error, category, type, setup, delivery, Flags, id, safe, lang at position [row,col {unknown-source}]: [3,5]
I dont understand becasue I do have error
d
Try setting error to
Boolean
rather than
String
.
Oh, and you marked the data classes as
@Serializable
?
d
@David Nedrow Yes in ktor I was trying to use
Copy code
import io.ktor.serialization.kotlinx.xml.*
for the XML certification. I have switch to just parcing the the XML first and then turning it into JSON to send back out to the client.
Copy code
io.ktor.serialization.kotlinx.xml.*
Needs a lot better documentation!
👍🏻 1
d
Especially up to date documentation.
h
@DavdF I appreciate that you are looking for support, and maybe this is an example not of your doing, but please be considerate when posting contents. The contents of your XML is not appropriate. Please remove it/replace it. Thank you
👍🏻 1
m
I did convert the xml to data classes using this webpage:
https://jsonformatter.org/xml-to-kotlin
Copy code
data class Data (
    val error: String,
    val category: String,
    val type: String,
    val setup: String,
    val delivery: String,
    val flags: Flags,
    val id: String,
    val safe: String,
    val lang: String
)

data class Flags (
    val nsfw: String,
    val religious: String,
    val political: String,
    val racist: String,
    val sexist: String,
    val explicit: String
)
🙌 1