https://kotlinlang.org logo
t

turansky

10/04/2018, 9:18 PM
JSON
Copy code
{
  "data": [
    {
      "id": "x1_1",
      "type": "x1"
    },
    {
      "id": "x2_1",
      "type": "x2",
      "children": [
        {
          "id": "y1_1",
          "type": "y1"
        },
        {
          "id": "y2_1",
          "type": "y2",
          "connectedItems": [
            "x1_1"
          ]
        }      
    }
  ]
}
Data classes
Copy code
interface X {
  val id: String
}

interface Y {
  val id: String
}

data class D1(data: Array<X>)

data class X1(id): X
data class X2(id, children: Array<Y>): X

data class Y1(id): Y
data class Y2(id, connectedItems): Y
If there any possibility to realize deserialization for this case (according
type
field)?
s

sandwwraith

10/07/2018, 3:58 PM
Not really for now, such format is not supported yet
t

turansky

10/16/2018, 8:11 PM
Is there any plans to support such format?
Is there any possibility to realize such logic via custom serializers/deserializers?
s

sandwwraith

10/17/2018, 12:00 PM
Yes, there are such plans, but no ETA for it yet. I think it is possible, using intermediate representation via JSON tree: https://github.com/Kotlin/kotlinx.serialization/blob/master/runtime/jvm/src/test/kotlin/kotlinx/serialization/formats/json/JsonTreeAndMapperTest.kt#L35
This is probably a problem which https://github.com/Kotlin/kotlinx.serialization/pull/254 is trying to solve
t

turansky

11/27/2018, 7:17 PM
Do you have a plan to solve this problem in next release?
s

sandwwraith

11/29/2018, 8:39 PM
yes
t

turansky

12/12/2018, 9:25 PM
Is there any aproximate date?
s

sandwwraith

12/13/2018, 9:24 AM
I think it would be around 1.3.20 Possibly eap library releases will follow Kotlin eap's
t

turansky

01/23/2019, 10:25 PM
Coming soon?
Is custom deserializer best solution for
1.3.20
+
0.10.0
?
s

sandwwraith

01/24/2019, 11:01 AM
Yes
t

turansky

01/24/2019, 11:04 AM
Will
by type
deserialization (like in Jackson) be available later?
s

sandwwraith

01/24/2019, 11:39 AM
Yes, we have it in the roadmap
t

turansky

01/30/2019, 4:48 PM
Is there any example of custom
by type
deserialization?
My example doesn't work as expected
Any ideas?
s

sandwwraith

02/03/2019, 5:20 PM
t

turansky

02/10/2019, 1:26 PM
Nonstrict mode required 🙂
Deserialization works
3 Views