Closed cambiata closed 3 years ago
Why do you need to have a native js object as the intermediary step? With json2object you can convert your object to a json string which pass the structured clone algorithm and therefor can be sent to/from a webworker, then convert it back to an haxe object.
Yes, ibilion, you're right - I don't really need that. But I'm thinking that not having to convert to/from string might shave some tiny processing and time...
Maybe, but then that time will be used by the javascript engine to clone the structure ;)
Good point! :-)
Hi Guillaume!
I want to find a solution for passing Haxe objects to/from WebWorkers, and because of the restrictions of the structured clone algorithm https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm, Haxe enums, maps etc have to be "serialized" to js objects containing only object literals.
Is there a way to use json2object without the "json" stringify step, only producing a simple js object? And the reverse, for recreating the Haxe object..?
Best! / Jonas