I want to calculate json object Size in KB/Mb.
there is a similar post here but it's in Java. Kotlin doesn't allow us to get bytes of a String.
how can I do it in Kotlin?
I want to calculate json object Size in KB/Mb.
there is a similar post here but it's in Java. Kotlin doesn't allow us to get bytes of a String.
how can I do it in Kotlin?
Is str.toByteArray().size
the thing you are looking for [1]?
By the way, the approach described in the linked post converts the object to string and then looks at the string size. Note that this is only an approximation to the actual object size in memory.
[1] https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/to-byte-array.html