更改json值的顺序

时间:2014-01-15 06:08:53

标签: json

我有一个json数据如下

[{
  "_id": "52cbafc5afcec877d925d116",
  "id": "52",
  "url": "172.34.56.7"
}, {
  "_id": "52c255e5cf0060b8cce84b4a",
  "id": "13",
  "url": "172.18.2.114"
}, {
  "_id": "52cbd018afcec877d925d131",
  "id": "49",
  "url": "172.16.2.120"
}, {
  "_id": "52d60c9eafcec877d925d17a",
  "id": "100",
  "url": "156.45.34.56"
}]

我想打印如下数据。(最后的数据首先出现)

[{
    "_id": "52d60c9eafcec877d925d17a",
    "id": "100",
    "url": "156.45.34.56"
  }, {
    "_id": "52cbd018afcec877d925d131",
    "id": "49",
    "url": "172.16.2.120"
  }, {
    "_id": "52c255e5cf0060b8cce84b4a",
    "id": "13",
    "url": "172.18.2.114"
  },
  [{
    "_id": "52cbafc5afcec877d925d116",
    "id": "52",
    "url": "172.34.56.7"
  }]

如何可能

2 个答案:

答案 0 :(得分:0)

实现Comparator,然后用它对Json数组进行排序。

答案 1 :(得分:0)

这可以使用

完成
data=data.reverse()