I don’t know what `json` or `obj` are here, so it’...
# announcements
t
I don’t know what
json
or
obj
are here, so it’s hard ot say what’s possible. But you may be able to do something like:
Copy code
val msg = json { obj( "a" to "b", "notes" to mutableListOf() ) }

(msg.array("notes") as MutableList).add(element)
v
yeah that’s Klaxon’s dsl hehe
t
But presumably,
json {}
converts
obj
to json, so your array has already been serialised.
v
I see good point
t
So as Jonathan says, you would need to populate the array before serialisation, and once serialised, you can’t change it.
If you need to modify the contents, you’re better off either doing so before passing
obj
to the
json {}
function, or deserialising, making your changes, and then serialising again
v
got it thanks guys @Tim Malseed & @itnoles)