1👍
✅
The code does not produce valid JSON, as you can see from your example: there is no comma between the lists.
You don’t want to produce JSON by concatenating strings. Instead, build up lists or dicts in Python, then dump to JSON at the end:
data = []
if users:
data.append([{'label': user.first_name, 'value': '/'+ user.username + '/'} for user in users])
if cols:
data.append([{'label': col.name, 'value': col.get_absolute_url()} for col in cols])
if fes:
data.append([{'label': fe.name, 'value': fe.get_absolute_url()} for fe in fes])
json_str = json.dumps(data)
Source:stackexchange.com