Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion json5/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def _dump_str(obj, ensure_ascii):

def _is_ident(k):
k = str(k)
if not _is_id_start(k[0]) and k[0] not in (u'$', u'_'):
if not k or not _is_id_start(k[0]) and k[0] not in (u'$', u'_'):
return False
for ch in k[1:]:
if not _is_id_continue(ch) and ch not in (u'$', u'_'):
Expand Down
3 changes: 3 additions & 0 deletions tests/lib_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ def test_supplemental_unicode(self):
# we can't test this there.
pass

def test_empty_key(self):
self.assertEqual(json5.dumps({'': 'value'}), '{"": "value"}')


if __name__ == '__main__': # pragma: no cover
unittest.main()