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

2.0: Removed generic serialization of objects/iterables #374

Closed
nzagorsky opened this issue Mar 10, 2020 · 4 comments
Closed

2.0: Removed generic serialization of objects/iterables #374

nzagorsky opened this issue Mar 10, 2020 · 4 comments
Labels
question Further information is requested

Comments

@nzagorsky
Copy link

nzagorsky commented Mar 10, 2020

Hello! First of all thank you for such a great library!
After recent updates (most probably release of 2.0.x version) it started to fail with serialization error.

TypeError: �DY��� is not JSON serializable  

Steps to reproduce:

import ujson
ujson.dumps(set([1, 2, 3]))

or

ujson.dumps(set())

Thank you!

@hugovk hugovk added the question Further information is requested label Mar 10, 2020
@hugovk
Copy link
Member

hugovk commented Mar 10, 2020

Thanks for the report, that'll be this removal 53f85b1:

Removed generic serialization of objects/iterables

The behavior of ujson has always been to try to serialize all objects in
any way possible. This has been quite a deviation from other json
libraries, including Pythons standard json module, and the source of a
lot of confusion and bugs. Removing this quirk moves ultrajson closer to
the expected behavior.

Instead of trying to coerce serialization ultrajson will now throw a
TypeError: "repr(obj) is not JSON serializable" exception.

The "�DY���" bit is another issue: #258.

@hugovk hugovk changed the title Set serialization issue Removed generic serialization of iterables Mar 10, 2020
@hugovk hugovk closed this as completed Mar 10, 2020
@hugovk hugovk pinned this issue Mar 12, 2020
@hugovk hugovk changed the title Removed generic serialization of iterables 2.0: Removed generic serialization of iterables Mar 12, 2020
@hugovk hugovk changed the title 2.0: Removed generic serialization of iterables 2.0: Removed generic serialization of objects/iterables Mar 13, 2020
@bauman
Copy link

bauman commented Mar 16, 2020

seems like this is bit controversial.

I'd like to express my support that this project should be limited to serializing and deserializing basic JSON objects as explicitly defined by RFC 7159 as fast and as resource efficient as possible. Generally accepted extensions like Inf and -Inf could stand to be left out as well.

ujson forks like nujson support extensions to numpy objects. Future forks can extend as needed into specific domains.

@murdav
Copy link

murdav commented Apr 21, 2020

Personally, I liked to have the feature of generic serialization of objects/iterables. It was working great, especially when it is needed to serialize complex objects and save them into DB (JSONField in PostgreSQL).

@VMAtm
Copy link

VMAtm commented May 8, 2020

This change is quite unexpected. We used this package for our REST API, our objects in memory are sets, and changing support for iterables pushes us to select another package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants