json: avoid extra string manipulation of dict keys
A key must be string per JSON spec, and that's also true for template dicts.
--- a/mercurial/templatefilters.py Fri Jun 09 21:45:22 2017 +0900
+++ b/mercurial/templatefilters.py Sun Apr 23 13:40:18 2017 +0900
@@ -234,7 +234,7 @@
elif isinstance(obj, bytes):
return '"%s"' % encoding.jsonescape(obj, paranoid=paranoid)
elif util.safehasattr(obj, 'keys'):
- out = ['%s: %s' % (json(k), json(v))
+ out = ['"%s": %s' % (encoding.jsonescape(k, paranoid=paranoid), json(v))
for k, v in sorted(obj.iteritems())]
return '{' + ', '.join(out) + '}'
elif util.safehasattr(obj, '__iter__'):