A map in Go is not ordered, so even the iteration is not the same between 
several iterations. You can see: https://blog.golang.org/go-maps-in-action
I suppose something similar occurs with objects in JS.

So, maybe you can iterate the map and output a slice and then sort the 
slice, that is maybe your currently approach.


On Wednesday, October 2, 2019 at 7:45:34 AM UTC-5, Tad Vizbaras wrote:
>
> I have sizable Go WASM application that creates map[string]interface{} and 
> passes to JS or reads from JS library.
> Go maps do not have predefined key order. But JS has object property order 
> predictable in JavaScript objects since ES2015.
>
> Problem: when JS objects are transferred from JS into Go and back they key 
> order becomes scrambled.
> At this point I have a small fix inside JS application that simply 
> reorders keys coming from Go back into JS.
> A bit of a hack but works.
>
> Question: is there better solution?
>
> My environment:
> 1. Go 1.13.
> 2. Chrome and Edge browsers.
> 3. Windows 10 desktop 64bits.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e22b0838-cc8f-4ea5-9586-dafd9f976542%40googlegroups.com.

Reply via email to