我想知道是否有任何方法可以使用Express JS对JSON响应进行排序
我的JSON文件与Postman一样:
{
"id":"",
"fname":"",
"lname":"",
"country":"",
"phonen":""
}
我想改变顺序并将phonen带到顶部。
喜欢
{
"id":"",
"phonen":"",
"fname":"",
"lname":"",
"country":""
}
答案 0 :(得分:2)
Javascript中的对象不保证订单you would read this relative response 在 bpierre 响应中,您可以实现
自ECMAScript 2015以来,使用Map对象可以替代。 Map与Object共享一些相似之处,并保证按键顺序 see the docu