【发布时间】:2018-01-16 15:30:18
【问题描述】:
我有一个这样的 json:
[
{
"tipe": "foo1",
"color": "red",
"size": 92,
"seq": 1,
"hasil": 0
},
{
"tipe": "foo2",
"color": "red",
"size": 92,
"seq": 2,
"hasil": 1
},
{
"tipe": "foo3",
"color": "red",
"size": 92,
"seq": 3,
"hasil": 0
}
]
我想重新定位json的结构以防hasil = 1到最后一个位置,并保留seq值,
在这里问之前我已经重新搜索过,很遗憾我不知道这个问题的正确关键字。
目的:
[
{
"tipe": "foo1",
"color": "red",
"size": 92,
"seq": 1,
"hasil": 0
},
{
"tipe": "foo3",
"color": "red",
"size": 92,
"seq": 2,
"hasil": 0
},
{
"tipe": "foo2",
"color": "red",
"size": 92,
"seq": 3,
"hasil": 1
}
]
有办法让它成为可能吗?
【问题讨论】:
-
对数组进行排序。这是你需要的。
-
这个问题貌似和JSON一点关系都没有……
标签: javascript json