Skip to content

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

@phillco

Description

@phillco

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)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions