pywebview: A call from CEF to js_api to a Python standard json library's dumps() returns a promise, but the resolved promise returns an object and not a string
Specification
-
pywebview version: I don’t know where to find the version. There’s no readme in the webview folder. Folder was created on 5th of june 2019.
-
platform / version: Windows 7, 32-bit
Description
A call from CEF to js_api to a Python standard json library’s dump() returns a promise, but the resolved promise returns an object and not a string
Here is the Javascript:
function json_stringify(object, loaded_handler){
promise1 = window.pywebview.api.json_stringify(object)
promise1.then((value) => {
console.log("type " + typeof(value))
loaded_handler(value)
})
}
setTimeout(function(){
json_stringify({}, console.log)
}, 3000)
The Python:
class python_interpreter_api:
def json_stringify(self, obj):
return str(json.dumps(obj))
python_interpreter_api = python_interpreter_api()
Side question: is there a way to make the js_api run Python functions synchronously? So that the javascript is halted, python is run, then javascript continues?
Note: I even added str() to json.dumps (which should be redundant) but that doesn’t work either.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (8 by maintainers)
Hahaha @r0x0r you had me on the edge of walking away mad; me screaming: “let the bugs be set free!!11” or me posting a mathematical logical proof of the problem with svg flow chart diagrams in the hopes that it would become clear. ^-^