[Python] Pretty print json but keep inner arrays on one line python

Discussão em 'Python' iniciado por Stack, Março 5, 2025.

  1. Stack

    Stack Membro Participativo

    I am pretty printing a json in Python using this code:

    json.dumps(json_output, indent=2, separators=(',', ': ')


    This prints my json like:

    {
    "rows_parsed": [
    [
    "a",
    "b",
    "c",
    "d"
    ],
    [
    "e",
    "f",
    "g",
    "i"
    ],
    ]
    }


    However, I want it to print like:

    {
    "rows_parsed": [
    ["a","b","c","d"],
    ["e","f","g","i"],
    ]
    }


    How can I keep the arrays that are in arrays all on one line like above?

    Continue reading...

Compartilhe esta Página