https://kotlinlang.org logo
#serialization
Title
# serialization
b

Berkay Özkan

11/09/2023, 12:37 AM
Hi, i want to deserialize response of elasticsearch query https://www.elastic.co/guide/en/elasticsearch/reference/8.11/sql-rest-format.html#_json
Copy code
"rows": [
    ["Peter F. Hamilton",  "Pandora's Star",       768, "2004-03-02T00:00:00.000Z"],
    ["Vernor Vinge",       "A Fire Upon the Deep", 613, "1992-06-01T00:00:00.000Z"],
    ["Frank Herbert",      "Dune",                 604, "1965-06-01T00:00:00.000Z"],
    ["Alastair Reynolds",  "Revelation Space",     585, "2000-03-15T00:00:00.000Z"],
    ["James S.A. Corey",   "Leviathan Wakes",      561, "2011-06-02T00:00:00.000Z"]
  ],
since its list of list, how can i deserialize to this:
Copy code
data Foo (
val author: String;
val name: String;
val page_count: Long,
val release_date: String
)
a

Adam S

11/09/2023, 1:01 AM
Formatting the data in a list without keys is called a tuple. There's some workarounds in this issue, I think that should get you started https://github.com/Kotlin/kotlinx.serialization/issues/1906