Skip to content

Commit

Permalink
[j8] Always use the J8 printer for 'json write'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy C committed Dec 27, 2023
1 parent ca30ed0 commit bcb8521
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions builtin/json_ysh.py
Expand Up @@ -87,26 +87,13 @@ def Run(self, cmd_val):

#log('json write indent %d', indent)

# TODO: We should use the new printer unconditionally
if self.is_j8:
buf = mylib.BufWriter()
self.printer.Print(val, buf, indent)
self.stdout_.write(buf.getvalue())
self.stdout_.write('\n')
else:
if mylib.PYTHON:
#if 0:
obj = cpython._ValueToPyObj(val)

j = yajl.dumps(obj, indent=indent)
sys.stdout.write(j)
if extra_newline:
sys.stdout.write('\n')
else:
buf = mylib.BufWriter()
self.printer.Print(val, buf, indent)
self.stdout_.write(buf.getvalue())
self.stdout_.write('\n')
buf = mylib.BufWriter()

# TODO: Call PrintMessage() vs. PrintJsonmessage()
self.printer.Print(val, buf, indent)

self.stdout_.write(buf.getvalue())
self.stdout_.write('\n')

elif action == 'read':
attrs = flag_spec.Parse('json_read', arg_r)
Expand Down

0 comments on commit bcb8521

Please sign in to comment.