• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ShivrajRath/jsonabc: Sorts JSON object alphabetically. It supports nested object ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

ShivrajRath/jsonabc

开源软件地址:

https://github.com/ShivrajRath/jsonabc

开源编程语言:

JavaScript 46.4%

开源软件介绍:

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




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap