Closed fkromer closed 4 years ago
The easy fix would be doing something like
seq.range(20).foreach(lambda x: print(json.dumps(x)))
Alternatively, you could use the extend feature (should really write docs for this) https://github.com/EntilZha/PyFunctional/pull/144
import functional
import json
@functional.pipeline.extend(final=True)
def to_json(elements):
return json.dumps(elements)
functional.seq.range(10).to_json()
# '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]'
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@EntilZha Thanks for letting me know.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I am writing a command line app and need human readable output of sequences/streams. In my particular use case (nested sequences) pretty-printed JSON would be most suitable. Right now
to_json
writes JSON to a file. Could we add plain conversion (similar toto_dict
) to JSON?