gregschlom
12/15/2016, 7:42 PM/*
I need to:
- Have Gson deserialize this, even there's no 0-arg constructor
- Have an exception thrown if "name" is null, missing, or not a string in the JSON data
- Have favoriteColor be "blue" if it's null or missing
*/
class Person(
val name: String,
val favoriteColor: String = "blue") {
}
gregschlom
12/15/2016, 7:42 PMgregschlom
12/15/2016, 7:43 PMgregschlom
12/15/2016, 7:45 PMnull
if I say that a kotlin type is non-nullable. I should get a deserialization excpetion instead. Not an NPE when I try to access the fieldjkwatson
12/15/2016, 8:01 PMgregschlom
12/15/2016, 8:04 PMname
null if it’s missing or null in the jsonjkwatson
12/15/2016, 8:05 PMjkwatson
12/15/2016, 8:05 PMgregschlom
12/15/2016, 8:06 PMjkwatson
12/15/2016, 8:06 PMgregschlom
12/15/2016, 8:07 PMjkwatson
12/15/2016, 8:07 PMgregschlom
12/15/2016, 8:11 PMgregschlom
12/15/2016, 8:11 PMsalomonbrys
01/17/2017, 1:36 PM2.5.0
is out 😉 As usual, everything in the changelog : https://github.com/SalomonBrys/Kotson/blob/master/CHANGELOG.md#250-17-01-2017altero
01/19/2017, 1:45 PMsorinirimies
01/20/2017, 11:38 PMsalomonbrys
01/21/2017, 11:37 AMIan
01/28/2017, 10:18 PMval event : String = gson.fromJson(returnEventStr)
Ian
01/28/2017, 10:18 PMIan
01/28/2017, 10:19 PMimport com.github.salomonbrys.kotson.*
but it’s greyed out, Idea says it’s not being usedIan
01/28/2017, 10:19 PMIan
01/29/2017, 3:26 PMsalomonbrys
01/29/2017, 4:25 PMfromJson
takes a JSON String and a Class and returns an object. Not sure what you are trying to achive hereIan
01/29/2017, 4:27 PMIan
01/29/2017, 4:28 PMsalomonbrys
01/29/2017, 4:35 PMval event : String = gson.fromJson<String>(returnEventStr)
works ?Ian
01/29/2017, 4:37 PMIan
01/29/2017, 4:39 PMsreich
02/12/2017, 8:56 PM