ShivrajRath/jsonabc

Sorts JSON object alphabetically. It supports nested objects, arrays and collections. Works offline and beautifies JSON object too.

JavaScript

161

62 commits

updated May 6, 2024

See the code

README

Build Status

JSON ABC

Sorts JSON object alphabetically. It supports nested objects, arrays and collections. Works offline and beautifies JSON object too.

Try it (Demo)

JSON ABC

Supports

  • Beautifies JSON
  • Sorts Plain Objects, Collections, Arrays
  • Has offline supports
  • IE9+ Support
  • Mobile/ Tablet friendly
  • Sorting plain arrays is optional

Download

npm install jsonabc

Usage

  1. Used directly in Node:
    var myJsonAbc = require("jsonabc");
    var sorted = myJsonAbc.sortObj({ c: 0, b: 1, a: 0 });
    
  2. Built by Browserify, for directly inclusion in the browser:
    <script src="dist/jsonabc.js"></script>
    <script>
      var output = jsonabc.sort(inputStr, noarray);
    </script>
    

Example

It converts this

{
  "object": {
    "b": 2,
    "a": 1,
    "d": 4,
    "c": 3
  },
  "array": ["d", "1", "c", "a", "b"],
  "collection": [
    {
      "b": 2,
      "a": 1,
      "d": 4,
      "c": 3
    },
    {
      "__b1": 2,
      "__a2": 1,
      "__d3": 4,
      "__c4": 3
    },
    ["d", "1", "c", "a", "b"]
  ]
}

to this

{
  "array": ["1", "a", "b", "c", "d"],
  "collection": [
    ["1", "a", "b", "c", "d"],
    {
      "__a2": 1,
      "__b1": 2,
      "__c4": 3,
      "__d3": 4
    },
    {
      "a": 1,
      "b": 2,
      "c": 3,
      "d": 4
    }
  ],
  "object": {
    "a": 1,
    "b": 2,
    "c": 3,
    "d": 4
  }
}

License: MIT

javascript
json
json-abc
sort
sorts-json
utility

Contributors

ShivrajRath

49 commits

nfreear

7 commits

KnakW

3 commits

cheazy

1 commits

ShivrajRath/jsonabc

Sorts JSON object alphabetically. It supports nested objects, arrays and collections. Works offline and beautifies JSON object too.

JavaScript

161

62 commits

updated May 6, 2024

See the code

README

Build Status

JSON ABC

Sorts JSON object alphabetically. It supports nested objects, arrays and collections. Works offline and beautifies JSON object too.

Try it (Demo)

JSON ABC

Supports

  • Beautifies JSON
  • Sorts Plain Objects, Collections, Arrays
  • Has offline supports
  • IE9+ Support
  • Mobile/ Tablet friendly
  • Sorting plain arrays is optional

Download

npm install jsonabc

Usage

  1. Used directly in Node:
    var myJsonAbc = require("jsonabc");
    var sorted = myJsonAbc.sortObj({ c: 0, b: 1, a: 0 });
    
  2. Built by Browserify, for directly inclusion in the browser:
    <script src="dist/jsonabc.js"></script>
    <script>
      var output = jsonabc.sort(inputStr, noarray);
    </script>
    

Example

It converts this

{
  "object": {
    "b": 2,
    "a": 1,
    "d": 4,
    "c": 3
  },
  "array": ["d", "1", "c", "a", "b"],
  "collection": [
    {
      "b": 2,
      "a": 1,
      "d": 4,
      "c": 3
    },
    {
      "__b1": 2,
      "__a2": 1,
      "__d3": 4,
      "__c4": 3
    },
    ["d", "1", "c", "a", "b"]
  ]
}

to this

{
  "array": ["1", "a", "b", "c", "d"],
  "collection": [
    ["1", "a", "b", "c", "d"],
    {
      "__a2": 1,
      "__b1": 2,
      "__c4": 3,
      "__d3": 4
    },
    {
      "a": 1,
      "b": 2,
      "c": 3,
      "d": 4
    }
  ],
  "object": {
    "a": 1,
    "b": 2,
    "c": 3,
    "d": 4
  }
}

License: MIT

javascript
json
json-abc
sort
sorts-json
utility

Contributors

ShivrajRath

49 commits

nfreear

7 commits

KnakW

3 commits

cheazy

1 commits

Languages

JavaScript

50.1%

HTML

25.4%

CSS

24.4%