-
Notifications
You must be signed in to change notification settings - Fork 364
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
Allow indent to be a str or None for compatibility with Python's json #517
Comments
I think it's worth going for full compatibility even though that requires a significant refactor. I wanted to look into this a while ago, but it got blocked by the buffer overflow issues (cf. #504) since it requires proper memory management. |
The refactor wasn't as difficult as I thought it was, so I added full indent support in #518 but I'm not sure if there are memory management issues. It would be good if someone could vet the code. |
This is a feature request to make ujson slightly more compatible with Python's json module.
The current version of ujson expects that
indent
is always specified as an int, otherwise it will raise a TypeError.However, Python's json module allows the user to specify indent as either an int, None, or a string. In Python, you can specify a string indent as something with non-space characters, but because of the way ujson is implemented, it would be harder to support that without a major refactor. As a compromise, it would be nice if ujson could accept indent as a string, verify that it only contains spaces, and then convert the number of spaces to an int for it's own internal usage.
With Python's json
Prints:
But in ujson
prints
I have a PR that will resolve this issue.
The text was updated successfully, but these errors were encountered: