#13182 closed Cleanup/optimization (fixed)
Remove useless whitespaces in JSON dump with indent option
Reported by: | Stephane Raimbault | Owned by: | martmatwarne |
---|---|---|---|
Component: | Core (Serialization) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | kmike84@…, charette.s@…, martmatwarne | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | yes | UI/UX: | no |
Description
When a JSON dump is done with the indent option, all lines are terminated by a whitespace and a newline.
The trailing whitespace is useless, it increases the file size and emits a warning in my editor and git.
The goal of my patch is to remove these whitespaces (specific to the JSON serializer).
Attachments (7)
Change History (28)
Changed 14 years ago by
Attachment: | dumpdata-json.patch added |
---|
comment:1 Changed 14 years ago by
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
Changed 13 years ago by
Attachment: | less-whitespace-json-serialize.diff added |
---|
Changed 13 years ago by
Attachment: | dump_without_patch added |
---|
Changed 13 years ago by
Attachment: | dump_with_patch added |
---|
comment:3 Changed 13 years ago by
Owner: | changed from nobody to gptvnt |
---|---|
Status: | new → assigned |
I tested the latest patch and ran the test. It seems to be working fine. I have attached the data dump I got in both the cases (with and without the patch) while testing.
comment:4 Changed 13 years ago by
Needs tests: | unset |
---|
comment:5 Changed 13 years ago by
Cc: | kmike84@… added |
---|
comment:6 Changed 12 years ago by
Type: | → New feature |
---|
comment:7 Changed 12 years ago by
Severity: | → Normal |
---|
Changed 12 years ago by
Attachment: | 13182.json-white-spaces.diff added |
---|
comment:8 Changed 12 years ago by
Triage Stage: | Accepted → Ready for checkin |
---|---|
Type: | New feature → Cleanup/optimization |
The patch looks great. I've just updated it to work with current trunk and rejigged the comments a little.
comment:10 Changed 12 years ago by
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
In that case I'm going to mark this wontfix. An explicitly installed simplejson will override the one Django ships with, so if you care about this then just pip install simplejson
comment:11 Changed 11 years ago by
Resolution: | wontfix |
---|---|
Status: | closed → new |
UI/UX: | unset |
This ticket should be reconsidered because Django 1.5 has removed its copy of simplejson in favour of json from Python's standard library (which is based on version 2.0.9 of simplejson). As a result there is no way to prevent having trailing whitespace in when using the JSON serializer.
See https://docs.djangoproject.com/en/dev/releases/1.5/#system-version-of-simplejson-no-longer-used
comment:12 Changed 11 years ago by
Cc: | charette.s@… added |
---|
comment:13 Changed 11 years ago by
Easy pickings: | set |
---|---|
Patch needs improvement: | set |
Triage Stage: | Ready for checkin → Accepted |
Unfortunately the patch doesn't apply any longer, so this isn't RFC.
comment:14 Changed 10 years ago by
Cc: | martmatwarne added |
---|---|
Owner: | changed from gptvnt to martmatwarne |
Status: | new → assigned |
Changed 10 years ago by
Attachment: | noTrailingWhitespace.diff added |
---|
comment:15 Changed 10 years ago by
Removing the two lines in the diff fixes the issue. I can't think of a reason why you'd want to have a blank line at the bottom but correct me if I'm wrong.
comment:16 Changed 10 years ago by
Patch needs improvement: | unset |
---|
comment:17 Changed 10 years ago by
Triage Stage: | Accepted → Ready for checkin |
---|
comment:18 Changed 10 years ago by
Triage Stage: | Ready for checkin → Accepted |
---|
Actually this doesn't completely work as it will mean when you do a command such as dumpdata that your prompt doesn't go to the next line
comment:19 Changed 10 years ago by
Patch needs improvement: | set |
---|
Changed 10 years ago by
Attachment: | less-whitespace-json-serialize-20130820.diff added |
---|
Updated to apply to master. Serialize tests pass.
comment:20 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Remove trailing whitespace and cosmetic changes (import of get_models, spaces)