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
See original GitHub issueSpecification
-
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.
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (8 by maintainers)
Top Results From Across the Web
Promise resolved but returns part of data - rest 'undefined'
Finally got it. It was problem with the schema which I have not adjusted (one schema was used for uploading data to MongoDB,...
Read more >Resolving the JavaScript Promise Error "TypeError: Cannot ...
This function is expected to return a Promise that should resolve to JSON data. The getGithubOrgs() function is then called with an argument ......
Read more >Promise API - The Modern JavaScript Tutorial
Promise.all takes an iterable (usually, an array of promises) and returns a new promise. The new promise resolves when all listed promises ......
Read more >JavaScript Promises: an introduction - web.dev
Promises simplify deferred and asynchronous computations. A promise represents an operation that hasn't completed yet.
Read more >You Must Know Python JSON Dumps, But Maybe Not All ...
We know that we can use the json.dumps() method to easily convert a Python dictionary object into a JSON string. However, this method...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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. ^-^
Fix is deployed to 3.0.2