(Mar-16-2020, 12:41 AM)qurr Wrote: Is it possible in python 3.8 to print list in one line rather than printing each item on new line via json.dumps? Are there any other json libraries that can do it?
I'm confused, it seems like that's the default behavior?
Output:
>>> import json
>>> json.dumps([
... [1, 2],
... [3, 4],
... ])
'[[1, 2], [3, 4]]'
(Mar-17-2020, 05:44 AM)ndc85430 Wrote: This seems a bit strange really. JSON is meant to be passed between machines, so formatting makes no difference to them.
I disagree strongly with this. Python's json.dumps method even has functionality for changing how the data looks, even though the dicts would be equal in Python (off the top of my hey, indent and sort_keys come to mind).
If the customer wants something, then that's what they want. End of story. I wish I could help, I'm just unclear on what the OP actually wants in spite of all the posts already.