Unexpected markup in kotlin (using ; Separate expressions on the same line)… here is a solution to the problem.
Unexpected markup in kotlin (using ; Separate expressions on the same line)
I used Kotlin in my
android project, it was developed on Java, and I used Kotlin data classes in my service layer
Now I want to add alternate labels in the serialization
@SerializedName(value="name", alternate={"person", "user"}) val title:String,
This gave me an unexpected token problem, which seems to be coming from Kotlin’s side
This seems to be a kotlin issue, can someone point me to the problem
Solution
I think this will get the job done :
@SerializedName(value="name", alternate=arrayOf("person", "user")) val title:String
The Kotlin compiler treats alternate={“person”, “user”} as alternate={"person", "user"}
function type .
Edited by 1blustone:
In Kotlin 1.2, this can be > by are implemented, but only in comments:
@SerializedName(value = "name", alternate = ["person", "user"]) val title:String