richie5um / vscode-sort-json

VSCode Extension to Sort JSON objects
https://marketplace.visualstudio.com/items?itemName=richie5um2.vscode-sort-json
MIT License
110 stars 19 forks source link

Sorting by data type. Grouping Primitive data type together and Complex data type together. #66

Open maxime4000 opened 2 years ago

maxime4000 commented 2 years ago

I'm looking at the documentation and I'm not sure how to interpret the docs about the settings configuration. I'm looking to sort JSON by Type, but I want it with those criteria :

I guess I have 4 criteria of grouping. Something like this order :

The goal is to make :

To my understanding, the most similar feature is sorting by type, but it separate different primitive type which I prefer if it wouldn't happen.

I don't think the settings allow this type of customization, would appreciate some help if it can allow it. Otherwise, take this as a feature request :)

maxime4000 commented 2 years ago

Here a JSON made to test the use case: I can provide with an expected sorting if ask. Otherwise I won't.

{
  "F": "string",
  "B": {
    "B": "string",
    "A": "string",
    "AObject": {
      "E": "string",
      "O": 3,
      "W": null,
      "H": 1,
      "B": false,
      "BObject": {
        "A": "string",
        "G": "string",
        "H": [
          {
            "C": "string",
            "A": "string"
          },
          {
            "C": "string",
            "A": {
              "A": "string"
            }
          }
        ],
        "B": {
          "A": "string"
        },
        "F": true,
        "D": {
          "A": "string",
          "D": "string",
          "C": "string"
        },
        "C": {
          "A": "string"
        },
        "E": "string"
      },
      "N": null,
      "ZObject": {
        "A": "string",
        "M": "string",
        "C": "string"
      },
      "M": "string",
      "L": 2,
      "D": "string",
      "R": false,
      "T": true,
      "C": "string"
    },
    "ZObject": {
      "A": "string",
      "G": "string",
      "D": "string",
      "C": "string"
    },
    "CObject": {
      "G": "string",
      "B": "string",
      "M": "string",
    }
  },
  "A": {
    "A": "string",
    "G": "string",
    "M": "string",
    "C": "string"
  },
  "C": {
    "A": "string",
    "G": "string",
    "M": "string",
    "C": "string"
  }
}
richie5um commented 2 years ago

Thanks for the suggestion. I'm not able to have a look at this at the moment. Let me know if you are able to have a look at the code and I can give you some suggestions.