Tuesday 14 May 2019

{JSON} sucks in kotlin/java

As a dev with web background, I am used to easily running a Json.parse() here and there and instantly I get to use my JSON object.

Recently as a noob App dev though... wow... are people just this incapable of answering Stack Overflow questions or what??

So if, like me, you were unable to parse JSON to an object in Kotlin and went down a rabbit hole for 3 hours, maybe this will help you:

val jsonObj = JSONObject("{\"valu\":\"77\"}")

var myVar: String? = nullif (jsonObj.has("valu")) {
    myVar = jsonObj.get("valu") as String
}

Devlog 8: AI and Radar explanation.