mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-15 01:24:29 +02:00
simplify json_out code
This commit is contained in:
10
jc/cli.py
10
jc/cli.py
@ -286,18 +286,16 @@ def json_out(data, pretty=False, env_colors=None, mono=False, piped_out=False, a
|
||||
separators = None
|
||||
indent = 2
|
||||
|
||||
j_data = json.dumps(data, indent=indent, separators=separators, ensure_ascii=ascii_only)
|
||||
|
||||
if not mono and not piped_out:
|
||||
# set colors
|
||||
class JcStyle(Style):
|
||||
styles = set_env_colors(env_colors)
|
||||
|
||||
return str(highlight(json.dumps(data,
|
||||
indent=indent,
|
||||
separators=separators,
|
||||
ensure_ascii=ascii_only),
|
||||
JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
|
||||
return str(highlight(j_data, JsonLexer(), Terminal256Formatter(style=JcStyle))[0:-1])
|
||||
|
||||
return json.dumps(data, indent=indent, separators=separators, ensure_ascii=ascii_only)
|
||||
return j_data
|
||||
|
||||
|
||||
def magic_parser(args):
|
||||
|
Reference in New Issue
Block a user