If I have a `Map<String, JsonObject>` is the...
# serialization
d
If I have a
Map<String, JsonObject>
is there any way to easily modify one of the entry's value in the
JsonObject
?
I'd suppose there's no
MutableJsonObject
...? But maybe a more efficient plus operator implementation to merge two JsonObjects?
d
JsonObject
implements
Map
and is just a wrapper around a
Map
. So you could do something like
Copy code
val merged = JsonObject(previousJsonObject + mapOf("key" to JsonPrimitive("value")))
Or
previousJsonObject.toMutableMap()
, then modify that map and finally create a new
JsonObject
again that wraps the mutable map.
e
fyi there's a
Map.plus(Pair)
overload
d
Thanks! That all sounds very good!
a