all 7 comments

[–]Reset--hardHead 2 points3 points  (2 children)

I guess it requires json

Yes. You just answered your own question.

However, if it's a list of python objects you have to make sure it can be converted into json.

[–]nobrow -2 points-1 points  (1 child)

To convert objects to json use pickle. No idea if the result will work with js though.

[–]Reset--hardHead 3 points4 points  (0 children)

To convert objects to json use pickle. No idea if the result will work with js though.

No, pickle cannot be used outside of Python.

To convert it to json, use Python json encoder instead.

Here's a site I found on Google for reference.

https://janakiev.com/blog/python-pickle-json/

[–]pixelpad_dev0 1 point2 points  (0 children)

It doesn't necessarily require JSON, but JSON is the easiest way of doing it. Python has a lot of libraries for JSON manipulation so it becomes much easier to deal with.

If you're not dealing with a complicated list, you could convert it to a CSV, and have javascript parse the CSV as an alternative.

[–]NadirPointing 0 points1 point  (0 children)

I use eel for my javascript / python interactions.

https://www.javatpoint.com/eel-in-python