tim
03/06/2020, 11:13 AMdata class Outer(val inner: Inner)
data class Inner(val value: Int)
val state = Outer(Inner(1))
val keyOuter = "inner"
val keyInner = "value"
state[keyOuter][keyInner] // returns 1
Ultimately I'd like to do is specify a 'path' so I can get at the nested value: dataClass["inner.someValue.value"]
(similar to how lodash does it for javascript objects).Mike
03/06/2020, 11:19 AMtim
03/06/2020, 11:29 AMMike
03/06/2020, 11:42 AMtim
03/06/2020, 12:28 PM{
id: String
attribute: {
someAttribute: {
value: Int
}
}
raw: List<Any>
...
}
There are two things I need to do with that object at runtime. The first is being able to get and set nested values based on a variable:
state.get("attributes.someAttribute.value")
and
state.set("attributes.someAttribute.value", 10)
and the second requirement is being able to deserialise from a Map (because the object is stored in Firestore)tim
03/06/2020, 12:30 PMMike
03/06/2020, 3:11 PMtim
03/06/2020, 3:33 PMtim
03/06/2020, 3:33 PMjimn
03/06/2020, 4:14 PMtim
03/06/2020, 4:16 PMtim
03/06/2020, 4:17 PM