I upgraded an app to django 1.3.1 and the json output changed from curly brackets to square brackets.
Before:
{
{
"code": "KENNEDYS08",
"duration": 23,
"preview_frame": 1,
}
}
After:
[
{
"code": "KENNEDYS08",
"duration": 23,
"preview_frame": 1,
}
]
The code that returns the json:
output = json.dumps(data, ensure_ascii=False, indent=2)
Is there an option for replacing the square brackets [] for curly brackets {}?
when you have {} in Json is the same as having a dictionary in python ! which means that in a dictionary you always need a key/value ! so the first one is incorrect! if was like that in previous version of Django, thats why the change for the [] version, which is the right one indeed, and should be followed!