In my WASM code, I’m getting a js.Value
that is a JavaScript object
, and shown here the JavaScript object is mapping with GO map[string]interface{}
In my code, I tried the below to get the data from the returned object, getting use from this code that is converting JSON to map[string]interface{}
:
ReadAll = js.FuncOf(func(this js.Value, args []js.Value) interface{} {
// defer ReadAll.Release()
cursor := this.Get("result")
if cursor.Truthy() {
_ = cursor.Get("key")
value := cursor.Get("value")
// Decode incoming json
jsonMap := make(map[string]interface{})
json.Unmarshal([]byte(value), &jsonMap)
// var content []map[string]interface{}
// json.Unmarshal([]byte(jsonMap["name"].(string)), &content)
Window.Call("alert", jsonMap)
cursor.Call("continue")
} else {
Window.Call("alert", "No more records")
}
return nil
})
But i got the error:
./cursor.go:20:25: cannot convert value (type js.Value) to type byte