amanda.hinchman-dominguez
01/21/2018, 3:57 PMedvin
01/21/2018, 3:58 PMJsonObject.string()
returns a String?
and your property called name
is defined as not nullable. You can change to JsonObject.getString()
etc instead, those will always return (and require) a value, and optionally takes a default value if the json document didn't contain a value for the key you gave it.amanda.hinchman-dominguez
01/21/2018, 3:58 PMedvin
01/21/2018, 3:59 PMjsonArray
if that is what you want, or you can change the structure of the JSON file to actually be a JsonObject, meaning it starts with curlies, not brackets.amanda.hinchman-dominguez
01/21/2018, 4:00 PMedvin
01/21/2018, 4:00 PM.toModel<ModelType>()
on the JsonArrayamanda.hinchman-dominguez
01/21/2018, 4:00 PMrows = JsonObject.getInt("rows")
There is no reference for getInt()edvin
01/21/2018, 4:00 PMloadJsonArray
in thereedvin
01/21/2018, 4:01 PMgetInt()
amanda.hinchman-dominguez
01/21/2018, 4:01 PMamanda.hinchman-dominguez
01/21/2018, 4:02 PMedvin
01/21/2018, 4:03 PMgetInt()
in your case, since this
is the json
parameter you sent in to the function.edvin
01/21/2018, 4:04 PMrows = getInt("rows")
- if "rows" in the json file is an integer that isamanda.hinchman-dominguez
01/21/2018, 4:04 PMint
the way I used string
. Does that mean there's an issue with SimpleIntegerProperty()?edvin
01/21/2018, 4:06 PMrowsProperty.value = int("rows")
, but I recommend you do rows = getInt("rows")
amanda.hinchman-dominguez
01/21/2018, 4:07 PMstring
when there is one for int
. Could it be that a SimpleStringProperty
could never be null when the same is not true for SimpleIntegerProperty
?amanda.hinchman-dominguez
01/21/2018, 4:09 PMedvin
01/21/2018, 4:09 PMamanda.hinchman-dominguez
01/21/2018, 4:10 PMamanda.hinchman-dominguez
01/21/2018, 4:11 PMedvin
01/21/2018, 4:12 PMval rows by rowsProperty
is defined as type Int
from Kotlin, while the val name by nameProperty
results in a Java String. Since that's a platform type, it allows null, while the Kotlin type Int doesn't accept null.amanda.hinchman-dominguez
01/21/2018, 4:12 PMjavaClass.getResource(url)
edvin
01/21/2018, 4:12 PMedvin
01/21/2018, 4:12 PMamanda.hinchman-dominguez
01/21/2018, 4:12 PMit
amanda.hinchman-dominguez
01/21/2018, 4:14 PMamanda.hinchman-dominguez
01/21/2018, 4:18 PMpoohbar
01/21/2018, 4:59 PMString
in Kotlin does not allow null, so I am not sure what you mean.edvin
01/21/2018, 6:25 PMamanda.hinchman-dominguez
01/21/2018, 7:54 PM