On Thu, Dec 1, 2016 at 10:30 AM, Cecil Westerhof <ce...@decebal.nl> wrote:
> I would prefer when it would generate:
>     '[
>      "An array",
>      "with several strings",
>      "as a demo"
>      ]'
>
> Is this possible, or do I have to code this myself?

> https://docs.python.org/3/library/json.html?highlight=indent#json.dump

>>>> json.dumps(["An array", "with several strings", "as a demo"], indent=0)
>'[\n"An array",\n"with several strings",\n"as a demo"\n]'
>>>> print(_)
>[
>"An array",
>"with several strings",
>"as a demo"
>]

As Zac stated the indent:
>>> print(json.dumps(["An array",{"Dummy":{'wop':'dop','dap':'dap'}}, "with 
>>> several strings", "as a demo"], sort_keys = True, indent=4))
[
    "An array",
    {
        "Dummy": {
            "dap": "dap",
            "wop": "dop"
        }
    },
    "with several strings",
    "as a demo"
]
>>>
This email is confidential and may be subject to privilege. If you are not the 
intended recipient, please do not copy or disclose its content but contact the 
sender immediately upon receipt.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to