GithubHelp home page GithubHelp logo

dfoverdx / vscode-sort-json Goto Github PK

View Code? Open in Web Editor NEW

This project forked from richie5um/vscode-sort-json

0.0 1.0 0.0 455 KB

VSCode Extension to Sort JSON objects

Home Page: https://marketplace.visualstudio.com/items?itemName=richie5um2.vscode-sort-json

License: MIT License

JavaScript 100.00%

vscode-sort-json's Introduction

What is it?

Alphabetically sorts the keys in selected JSON objects.

Please take care using this - I've tried to ensure it won't invalidate your JSON. But, as it has to parse > sort > stringify, there is a chance it'll lose something. It should be fine for plain JSON.

Buy me a coffee

Install

  • Install via VSCode extensions install

Usage

  • Select a JSON object (note, it uses full lines so ensure the selected lines are a valid JSON object)
  • Run the extension (Cmd+Shift+P => Sort JSON)

Updates

  • 1.18.0: orderOverride and orderUnderride can use Regular Expressions.
  • 1.17.0: Sort by type (experimental code).
  • 1.16.0: Sort by values (experimental code).
  • 1.15.0: Change algorithm to better cope with JSON quirks.
  • 1.14.0: Sortable alphanumerically (a2 < a10).
  • 1.13.0: Sortable by key length.
  • 1.12.0: Improvements to JSONC comment detection - thanks 'reporter123'.
  • 1.11.0: Tries to use normal JSON outputter for some known JSON issues.
  • 1.10.1: Removes (simple) comment lines from JSON before sorting.
  • 1.9.2: Now sorts the whole file if there is no selected text.
  • 1.9.0: Now sorts selected JSON text, even if that is embedded in a JSON object - note, doesn't preserve indents.
  • 1.8.0: Sorts objects within arrays.

Example

Example

Settings

  • You can override the sort order (note: this applies to all levels and overrides reverse sort too). Add this to your preferences (settings.json):
    • "sortJSON.orderOverride": ["name", "version", "description"]
  • You can underride the sort order (note: this applies to all levels and underrides reverse sort too). Add this to your preferences (settings.json):
    • "sortJSON.orderUnderride": ["dependencies", "devDependencies"]

For each of these settings, you may supply JavaScript RegExp's.

  • "sortJSON.orderOverride": ["/^(NAME|VERSION)$/i", "description"]

vscode-sort-json's People

Contributors

richie5um avatar mrmlnc avatar haleyhitch avatar jdx avatar reporter123 avatar wrathza avatar dependabot[bot] avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.