Is there an easy way to accomplish this (embedding...
# serialization
d
Is there an easy way to accomplish this (embedding raw json into the result -- maybe some annotation?):
Copy code
@Serializable data class Foo(val bar: Int, val json: String)

val sample = Foo(1, """{"some": "json"}""")

val result = Json.encodeToString(sample)

// The result should be: { "bar": 1, "json": { "some": "json" } }
?
e
d
So currently, I would just use
JsonElement
for the
json
field and it would work?
e
if you're ok with writing
Copy code
Foo(
    bar = 1,
    json = buildJsonObject {
        put("some", "json")
    }
)
then yes, that currently works
d
I have that on another layer, I was hoping not to expose it beyond there... but I guess I currently have no choice... but thanks for that issue... at least I know I'll be able to replace this in the near future 🙂!