I'm using a js library in my brython code that wants to take JS dictionary/objects. Passing brython dictionary objects doesn't work, and I'm having trouble figuring out how to convert a python dict into a JSObject in my brython code, such that I could pass into this JS library.
I've found I can use:
import json
my_dict = {'a': 1, 'b': 2}
js_obj = window.JSON.parse(json.dumps(my_dict))
but that seems pretty inefficient. Also, note that I need to use the js version of JSON.parse() from window, not the brython version (javascript.JSON.parse()), since that one returns a python dict.
Is there a cleaner, faster way to do this? I'd love something like: javascript.to_jsobj(python_dict)
Thanks!
Ben