Hey All I am building a JsonObject like following ...
# javascript
s
Hey All I am building a JsonObject like following , I want to
put(key="data",*ArrayBuffer)*
but put only accepts JsonElement , so how to do this? as JS Function expects an ArrayBuffer there... Any Help is Appreciated!
m
There is no ArrayBuffer in JSON. How should it be serialized to JSON? As a String? As an Array of Numbers?
JsonObject
is for kotlinx-serialization. Do you mean a plain JS object with
jsObject
?
s
Javascript function is expecting ArrayBuffer
yes plain jsObject
m
buildJsonObject
is not meant for JavaScript objects. You can either define an
external interface
for your expected type or use
js { … }
from package
org.jetbrains:kotlin-extensions:1.0.1-pre.148-kotlin-1.4.30
.
Copy code
js {
   this["type"] = 3
   // ...
}
s
image.png
@Marc Knaup above seems right?
m
No
Don’t use
JsonPrimitive
That’s also kotlinx-serialization
Just pass
3
and
"Cover Art"
And you can use
js
instead of
jsObject<dynamic>
s
ohhh okay thanks