Skip to content

TypeError: Decimal is not JSON serializable when submitting job #29

Closed
@craiga

Description

@craiga

Decimals aren't handled in client.job.create.

from decimal import Decimal
from zencoder import Zencoder

client = Zencoder('API_KEY')
client.job.create('s3://bucket/key.mp4',
                  outputs=[{'width': Decimal(300)}])

…causes:

Traceback (most recent call last):
  File "test.py", line 9, in <module>
    outputs=[{'width': Decimal(300)}])
  File "…/zencoder/core.py", line 350, in create
    return self.post(self.base_url, body=json.dumps(data))
  File "…/json/__init__.py", line 230, in dumps
    return _default_encoder.encode(obj)
  File "…/json/encoder.py", line 192, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "…/json/encoder.py", line 250, in iterencode
    return _iterencode(o, 0)
  File "…/json/encoder.py", line 173, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: Decimal('300') is not JSON serializable

I'm retrieving job settings from DynamoDB with boto and simplejson which seems to like returning numbers as Decimals.

Metadata

Metadata

Assignees

No one assigned

    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