Last active
June 16, 2020 20:59
-
-
Save GabriellCosta/db4869b1f8b3ad05bf3e4e3984454372 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.gson.Gson | |
//Nosso enum para teste | |
enum class TestEnum { | |
FIRST, | |
SECOND | |
} | |
//Uma classe contendo uma lista de enums | |
data class EnumTypeDTO( | |
val type: List<TestEnum> | |
) | |
//Criamos um simples json para validar como sera feita a converção | |
val api = """ | |
{ | |
type: [first, FIRST] | |
} | |
""" | |
val gson = Gson() | |
val result = gson.fromJson(api, EnumTypeDTO::class.java) | |
//Podemos aqui ver o resultado então | |
println("Enum type: $result") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment