Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js: introduce utilities to convert JavaScript objects to Python ones #2716

Open
phillco opened this issue Jan 10, 2025 · 0 comments
Open

js: introduce utilities to convert JavaScript objects to Python ones #2716

phillco opened this issue Jan 10, 2025 · 0 comments

Comments

@phillco
Copy link
Member

phillco commented Jan 10, 2025

We can't use a list comprehension here because changes it is not a true Python list, it's a QuickJS array which doesn't support that. We also don't have the ability to convert these JavaScript objects to Python with a one shot utility because certain reflection data is missing per Andreas.

But what we could do is make simple wrapping utilities that will convert one level of the tree:

  • JavaScript array to Python list (just does a iteration like this without looking at the objects in the array)
  • JavaScript dictionary to Python dictionary (you would have to pass exactly the keys you expect)

With this approach, we can contain the weirdness of the JavaScript objects to where we get them, requiring a couple of utility calls, and use proper Python code thereafter.

Originally posted by @phillco in #2709 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant