Last active
June 10, 2017 23:37
-
-
Save hameno/b5f867bbe3a3484deffd1bac3ec515c9 to your computer and use it in GitHub Desktop.
Bug with Kotlin + Moshi
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.squareup.moshi.Json | |
import com.squareup.moshi.KotlinJsonAdapterFactory | |
import com.squareup.moshi.Moshi | |
import org.junit.Test | |
data class DataClass( | |
@Json(name = "par1") val par1: String?, | |
@Json(name = "par2") val par2: String?, | |
@Json(name = "par3") val par3: String?, | |
@Json(name = "par4") val par4: String?, | |
@Json(name = "par5") val par5: String?, | |
@Json(name = "par6") val par6: String?, | |
@Json(name = "par7") val par7: String?, | |
@Json(name = "par8") val par8: String?, | |
@Json(name = "par9") val par9: String?, | |
@Json(name = "par10") val par10: String?, | |
@Json(name = "par11") val par11: String?, | |
@Json(name = "par12") val par12: String?, | |
@Json(name = "par13") val par13: String?, | |
@Json(name = "par14") val par14: String?, | |
@Json(name = "par15") val par15: String?, | |
@Json(name = "par16") val par16: String?, | |
@Json(name = "par17") val par17: String?, | |
@Json(name = "par18") val par18: String?, | |
@Json(name = "par19") val par19: String?, | |
@Json(name = "par20") val par20: String?, | |
@Json(name = "par21") val par21: String?, | |
@Json(name = "par22") val par22: String?, | |
@Json(name = "par23") val par23: String?, | |
@Json(name = "par24") val par24: String?, | |
@Json(name = "par25") val par25: String?, | |
@Json(name = "par26") val par26: String?, | |
@Json(name = "par27") val par27: String?, | |
@Json(name = "par28") val par28: String?, | |
@Json(name = "par29") val par29: String?, | |
@Json(name = "par30") val par30: String?, | |
@Json(name = "par31") val par31: String?, | |
@Json(name = "par32") val par32: String?, | |
@Json(name = "par33") val par33: String? | |
) | |
val json = """ | |
{ | |
"par1": "val1", | |
"par2": "val2", | |
"par3": "val3", | |
"par4": "val4", | |
"par5": "val5", | |
"par6": "val6", | |
"par7": "val7", | |
"par8": "val8", | |
"par9": "val9", | |
"par10": "val10", | |
"par11": "val11", | |
"par12": "val12", | |
"par13": "val13", | |
"par14": "val14", | |
"par15": "val15", | |
"par16": "val16", | |
"par17": "val17", | |
"par18": "val18", | |
"par19": "val19", | |
"par20": "val20", | |
"par21": "val21", | |
"par22": "val22", | |
"par23": "val23", | |
"par24": "val24", | |
"par25": "val25", | |
"par26": "val26", | |
"par27": "val27", | |
"par28": "val28", | |
"par29": "val29", | |
"par30": "val30", | |
"par31": "val31", | |
"par32": "val32", | |
"par33": "val33" | |
} | |
""" | |
class Tests { | |
@Test | |
fun bug() { | |
val moshi = Moshi.Builder().add(KotlinJsonAdapterFactory()).build() | |
val jsonAdapter = moshi.adapter(DataClass::class.java) | |
val dataClass = jsonAdapter.fromJson(json) | |
System.out.println(dataClass) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment