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

Can't print CreateOrderResponse because not JSON serializable #87

Closed
theimpostor opened this issue Dec 6, 2024 · 2 comments
Closed

Comments

@theimpostor
Copy link

Trying to use dumps as recommended by the readme with the CreateOrderResponse, getting the following error:

  File "/usr/src/app/./cbp-cli.py", line 111, in <module>
    order_id = place_order_with_timeout(factor, 2)
  File "/usr/src/app/./cbp-cli.py", line 81, in place_order_with_timeout
    fprint(dumps(order, indent=2))
           ~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
          ~~~~~~^^^^^
  File "/usr/local/lib/python3.13/json/encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/lib/python3.13/json/encoder.py", line 261, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/lib/python3.13/json/encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
                    f'is not JSON serializable')
TypeError: Object of type CreateOrderResponse is not JSON serializable
Copy link

github-actions bot commented Dec 6, 2024

Thank you for reporting! If this is an SDK specific issue, we will look into it and get back to you soon. If this is an API related request, report it in our Advanced API Discord instead (use this invite link if it's your first time accessing the Discord).

@urischwartz-cb
Copy link
Contributor

Can you try using the to_dict() function on the order object like so:
print(dumps(order.to_dict(), indent=2))

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

No branches or pull requests

2 participants