molsonkiko / JsonToolsNppPlugin

A Notepad++ plugin providing tools for JSON like linting, querying, a tree view, and CSV conversion.
Apache License 2.0
70 stars 9 forks source link

[Feature Request] Having a minimum length in an array before pretty printing it #39

Closed Kiryonn closed 2 months ago

Kiryonn commented 1 year ago

basically making that thing:

{
    "inputs": "#_#_",
    "values": [
        [
            11,
            15
        ],
        [
            16,
            15
        ],
        [
            11,
            17
        ],
        [
            16,
            17
        ],
        [
            13,
            25
        ]
    ]
}

into this:

{
    "inputs": "#_#_",
    "values": [
        [11, 15],
        [16, 15],
        [11, 17],
        [16, 17],
        [13, 25]
    ]
}
molsonkiko commented 1 year ago

Hmmm, interesting idea. I deliberately made my PPrint pretty-printing algorithm as simple as possible because I didn't feel like dealing with the added complexity of so many extra knobs to turn, but your suggestion sounds reasonable.

The main issue I see with your idea is figuring out a good way to communicate it to users.

Thanks for your feedback.

molsonkiko commented 1 year ago

My current inclination is not to add a new setting, but add a new way to selectively pretty-print or compress only some arrays/objects without changing the formatting of the rest of the document.

Still not sure of the exact implementation, but probably what I will do is add some options to the right-click menu when right-clicking on a location that has a json node. These right-click options might include path to current location, pretty-print just this node, and compress just this node.

Don't be surprised if it takes me a while to get around to this. I'm currently working on an irritating refactor of RemesPath.

Kiryonn commented 1 year ago

Take your time champ, I'm not the kind that complains to hard working people

molsonkiko commented 10 months ago

My new ability to parse multiple selections isn't exactly what you're looking for, but it can help:

[
    [
    0,
    0,
    0
],
    [
    1,
    2,
    3
],
    [
    2,
    4,
    6
],
    [
    3,
    6,
    9
],
    [
    4,
    8,
    12
]
]

can just be multi-selected (by selecting everything after the opening square brace and then using the Select every valid JSON in selection command) and compressed to convert it into this:

[
    [0,0,0],
    [1,2,3],
    [2,4,6],
    [3,6,9],
    [4,8,12]
]
molsonkiko commented 10 months ago

Multi-selecting only certain JSON in a document just got a lot easier, thanks to the new select JSON or JSON's children from treeview feature.

I won't go into too much detail, but basically you can select only a certain JSON element (or its children) and then pretty-print or compress those selections independently from the rest of the document. This goes most of the rest of towards making this sort of manipulation easy, and I'm not particularly inclined to continue working on this in the near future.

molsonkiko commented 2 months ago

I am closing this issue, and have no intention of implementing any feature that I previously mentioned considering. See #61 for a relevant tutorial.