The dangers of JSON + default values

54 · Daniel Lew · June 23, 2021, 1:04 p.m.
The following code converts an object to JSON and then back again: val adapter = Moshi.Builder().build().adapter(Foo::class.java) val foo = Foo(bar = null) val json = adapter.toJson(foo) val foo2 = adapter.fromJson(json) check(foo == foo2) I think most of us would expect check() to pass, but...