Bug 8866

Summary: Home-brew JSON encoding is ad hoc and incomplete
Product: [Build System, Metadata & Runtime] Toaster Reporter: Elliot Smith <elliot.smith>
Component: toasterAssignee: Toaster default assignee <toaster>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: Medium CC: belen.barros.pena, david.reyna, jessica.zhang, jose.perez.carranza, stanciux.mihail
Version: 2.1   
Target Milestone: Future   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Elliot Smith 2016-01-04 11:48:07 UTC
The JSON encoder used to convert querysets to JSON responses is hand-cranked and incomplete. It recently caused an issue where we had a decimal field in a queryset and our encoder didn't know what to do with it, so it failed with a mostly incomprehensible error.

objtojson() in toastergui/views.py is the main offender, closely followed by the code locations which call that function.

Rather than use objtojson() and friends, we should use the Django JSON encoder as far as possible, and maybe even the Django JSON HTTP response classes when encoding the body of a response.