Skip to content

Add option(s) to force PPrint to print inline jsons for same layout without considering its length? #58

@powof2

Description

@powof2

Hi there,

This is pretty:

{
    "employees": [
        {
            "id": 213,
            "name": "franc",
            "another": [[{"abc": "test"}, {"xyz": "nnnbbbbbbbbbbbbbbbb"}]] // this is perfectly inlined
        }
    ]
}

With longer xyz, it becomes this (which is not what i wanted)

{
    "employees": [
        {
            "id": 213,
            "name": "franc",
            "another": [
                [{"abc": "test"}, {"xyz": "nnnbbbbbbbbbbbbbbbbbbbbbbbbbb"}] // becomes 3 lines with longer 'xyz', not good but still ok
            ]
        }
    ]
}

With even longer xyz:

{
    "employees": [
        {
            "id": 213,
            "name": "franc",
            "another": [
                [
                    {"abc": "test"},
                    {
                        "xyz": "nnnbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" // not pretty anymore
                    }
                ]
            ]
        }
    ]
}

With above longest example, what i expected:

{
    "employees": [
        {
            "id": 213,
            "name": "franc",
            "another": [[{"abc": "test"}, { "xyz": "nnnbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" } ]]
        }
    ]
}

Can this be done by adding options to ignore value length for same layout when PPrint? or maybe add options to PPrint by indent levels?

Thank you, for the great tool.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions