gaetan
02/05/2018, 2:39 PMinterface GeoJson{
val type:String
val coordinates:Array<*>
fun asPoint() = Point(coordinates as Array<Double>)
}
data class Point(val coordinates:Array<Double>)
fun main(args: Array<String>) {
val json = """{"type":"Point", "coordinates":[1.0, 2.0]}"""
val obj = JSON.parse<GeoJson>(json).asPoint()
println("${obj.coordinates}")
}
https://try.kotlinlang.org/#/UserProjects/2fobglofrrpnr9b0pru299uu31/6d1saqhqrbndev90djqurmuiv0benleggiero
02/06/2018, 4:28 AMtrathschlag
02/06/2018, 8:28 AMgaetan
02/06/2018, 8:52 AMbashor
02/07/2018, 6:20 PMbashor
02/07/2018, 6:28 PMgaetan
02/07/2018, 8:01 PMUnhandled JavaScript exception:
TypeError: JSON.parse(...).asPoint is not a function
gaetan
02/07/2018, 8:02 PMgaetan
02/07/2018, 8:10 PMJSON.parse
we must use external interfaces
that can’t be in a common module. I must test the performance of deserialization with external interfaces, followed by a copy inside common classes. The problem is the size of GeoJSON files which can be big.bashor
02/08/2018, 1:33 PMbashor
02/08/2018, 1:41 PMbashor
02/08/2018, 1:41 PMgaetan
02/09/2018, 9:04 AMgaetan
02/09/2018, 9:05 AMbashor
02/09/2018, 9:29 AMgaetan
02/09/2018, 7:36 PM