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

Add a default keyword argument to dumps #470

Merged
merged 1 commit into from Sep 6, 2021
Merged

Conversation

garenchan
Copy link
Contributor

@garenchan garenchan commented Aug 31, 2021

dump and dumps functions in python json stdlib have a default keyword argument.
It's useful for serializing complex objects. So I think supporting this argument will improve
compatibility and flexibility of ujson.

https://docs.python.org/3/library/json.html

If specified, default should be a function that gets called for objects that can’t otherwise be serialized. It should return a JSON encodable version of the object or raise a TypeError. If not specified, TypeError is raised.

This should resolve #436 .

@garenchan garenchan force-pushed the ck-dev branch 2 times, most recently from 6f80bf2 to ff9d82e Compare August 31, 2021 14:01
@garenchan garenchan changed the title Add an default keyword argument to dumps Add a default keyword argument to dumps Aug 31, 2021
@codecov-commenter
Copy link

codecov-commenter commented Sep 1, 2021

Codecov Report

Merging #470 (f7d9ec1) into main (8f5ad61) will increase coverage by 0.29%.
The diff coverage is 98.11%.

❗ Current head f7d9ec1 differs from pull request most recent head b366434. Consider uploading reports for the commit b366434 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #470      +/-   ##
==========================================
+ Coverage   88.65%   88.94%   +0.29%     
==========================================
  Files           6        6              
  Lines        1631     1683      +52     
==========================================
+ Hits         1446     1497      +51     
- Misses        185      186       +1     
Impacted Files Coverage Δ
python/objToJSON.c 84.52% <96.29%> (+0.76%) ⬆️
tests/test_ujson.py 99.54% <100.00%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f5ad61...b366434. Read the comment docs.

tests/test_ujson.py Outdated Show resolved Hide resolved
tests/test_ujson.py Outdated Show resolved Hide resolved
tests/test_ujson.py Outdated Show resolved Hide resolved
dump and dumps functions in python json stdlib have a default keyword argument.
It's useful for serializing complex objects. Supporting this argument will improve compatibility and flexibility of ujson.
Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@hugovk hugovk merged commit dc48284 into ultrajson:main Sep 6, 2021
@garenchan garenchan deleted the ck-dev branch September 23, 2021 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: Added For new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ujson should support the default parameter from the stdlib implementation
3 participants