Skip to content

Provide a tuple serializer #9

Closed
@aSemy

Description

@aSemy

Instead of

@Serializable
class Tiles(
  val tiles: List<Tile>,
)

@Serializable
data class Tile(
  val x: Int,
  val y: Int,
  val type: String,
)

being converted to

interface Tiles{
  tiles: Tile[];
}

interface Tile{
  x: Int;
  y: Int;
  type: string;
}

type Int = number

instead create a tuple, because it's more compact when it's encoded to JSON.

Something like...

@Serializable(with = TupleSerializer::class)
data class Tile(
  val x: Int,
  val y: Int,
  val type: String,
)
type Tile = [Int, Int, string]

This would also provide a good demonstration of how the generated Typescript is affected by custom descriptors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions