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

Code not working due to passenger issue #7

Open
valentinthoss opened this issue May 23, 2024 · 2 comments
Open

Code not working due to passenger issue #7

valentinthoss opened this issue May 23, 2024 · 2 comments

Comments

@valentinthoss
Copy link

valentinthoss commented May 23, 2024

I get the error

"Object of type Passenger is not JSON serializable"

Here is the complete error:

nj.findOffers("Wien","Rom",datetime.date(2024,6,1),oebb.MA)
Traceback (most recent call last):
File "", line 1, in
File "/Users/vthoss/Jupyter/main.py", line 131, in findOffers
response = self.__session.post(
^^^^^^^^^^^^^^^^^^^^
File "/Users/vthoss/anaconda3/lib/python3.11/site-packages/requests/sessions.py", line 637, in post
return self.request("POST", url, data=data, json=json, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/vthoss/anaconda3/lib/python3.11/site-packages/requests/sessions.py", line 575, in request
prep = self.prepare_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/vthoss/anaconda3/lib/python3.11/site-packages/requests/sessions.py", line 486, in prepare_request
p.prepare(
File "/Users/vthoss/anaconda3/lib/python3.11/site-packages/requests/models.py", line 371, in prepare
self.prepare_body(data, files, json)
File "/Users/vthoss/anaconda3/lib/python3.11/site-packages/requests/models.py", line 511, in prepare_body
body = complexjson.dumps(json, allow_nan=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/vthoss/anaconda3/lib/python3.11/json/init.py", line 238, in dumps
**kw).encode(obj)
^^^^^^^^^^^
File "/Users/vthoss/anaconda3/lib/python3.11/json/encoder.py", line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/vthoss/anaconda3/lib/python3.11/json/encoder.py", line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
File "/Users/vthoss/anaconda3/lib/python3.11/json/encoder.py", line 180, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type Passenger is not JSON serializable

@KevinW1998
Copy link
Owner

What passenger and route data did you use?

@KevinW1998
Copy link
Owner

You probably want do something like this:

res = jetter.findOffers("Wien","Rom",date(2024,6,1),[MA.to_dict()])

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

2 participants