google / json_serializable.dart

Generates utilities to aid in serializing to/from JSON.
https://pub.dev/packages/json_serializable
BSD 3-Clause "New" or "Revised" License
1.54k stars 392 forks source link

Question: Will this packages support `extension types` like `kotlinx.serialization`? #1405

Open jpoh281 opened 4 months ago

jpoh281 commented 4 months ago

Kotlin's JSON serialization library(kotlinx.serialization) supports the value class in the following way:

Code:

@Serializable
@JvmInline
value class Color(val rgb: Int)

@Serializable
data class NamedColor(val color: Color, val name: String)

fun main() {
  println(Json.encodeToString(NamedColor(Color(0), "black")))
}

Json:

{"color": 0, "name": "black"}

I'm wondering if this package will support Json serialization in a similar way to Kotlin.