mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-21 00:19:42 +02:00
move separators to a variable
This commit is contained in:
@ -380,6 +380,7 @@ def versiontext():
|
||||
|
||||
def json_out(data, pretty=False, env_colors=None, mono=False, piped_out=False):
|
||||
"""Return a JSON formatted string. String may include color codes or be pretty printed."""
|
||||
separators = (',', ':')
|
||||
if not mono and not piped_out:
|
||||
# set colors
|
||||
class JcStyle(Style):
|
||||
@ -389,13 +390,13 @@ def json_out(data, pretty=False, env_colors=None, mono=False, piped_out=False):
|
||||
return str(highlight(json.dumps(data, indent=2, ensure_ascii=False),
|
||||
JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
|
||||
else:
|
||||
return str(highlight(json.dumps(data, separators=(',', ':'), ensure_ascii=False),
|
||||
return str(highlight(json.dumps(data, separators=separators, ensure_ascii=False),
|
||||
JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
|
||||
else:
|
||||
if pretty:
|
||||
return json.dumps(data, indent=2, ensure_ascii=False)
|
||||
else:
|
||||
return json.dumps(data, separators=(',', ':'), ensure_ascii=False)
|
||||
return json.dumps(data, separators=separators, ensure_ascii=False)
|
||||
|
||||
|
||||
def magic_parser(args):
|
||||
|
Reference in New Issue
Block a user