stephanmg
08/24/2020, 3:49 PMRob Elliot
08/24/2020, 4:12 PMjef
08/24/2020, 5:27 PMjef
08/24/2020, 5:27 PMRob Elliot
08/24/2020, 5:33 PMjef
08/24/2020, 5:39 PMstatically type checked data structure in a way that mirrors as closely as possible the shape of the actual databut serializing and deserializing would do this
jef
08/24/2020, 5:40 PMRob Elliot
08/24/2020, 5:45 PMjef
08/24/2020, 5:48 PMRob Elliot
08/24/2020, 5:51 PMjef
08/24/2020, 5:56 PMjef
08/24/2020, 5:56 PM<a>
<b>
<c>
<foo>"hello"</foo>
<bar>45</bar>
</c>
</b>
</a>
you'd do something like this:
data class A(val b: B)
data class B(val c: C)
data class C(val foo: String, val bar: Int)
@Test
fun test() {
val test = XmlMapper().writeValueAsString(A(B(C(foo = "test", bar = 42))))
println(test)
}
jef
08/24/2020, 5:57 PM<A><b><c><foo>test</foo><bar>42</bar></c></b></A>
jef
08/24/2020, 5:57 PMdata class A(val b: B) {
data class B(val c: C) {
data class C(val foo: String, val bar: Int)
}
}
@Test
fun test() {
val test = XmlMapper().writeValueAsString(A.B.C(foo = "test", bar = 42))
println(test)
}
gives an output of:
<C><foo>test</foo><bar>42</bar></C>
jef
08/24/2020, 5:59 PMRob Elliot
08/24/2020, 6:00 PMjef
08/24/2020, 6:02 PMdata class A(
val b: Any = object {
val c: Any = object {
val foo: String = ""
val bar: Int = 0
}
}
)
@Test
fun test() {
val test = XmlMapper().writeValueAsString(A())
println(test)
}
jef
08/24/2020, 6:02 PM<A><b><c><foo></foo><bar>0</bar></c></b></A>
jef
08/24/2020, 6:03 PMRob Elliot
08/24/2020, 6:18 PMjef
08/24/2020, 6:19 PM