jQuery按原始顺序获取JSON(有效JSON)

时间:2019-10-07 09:07:15

标签: javascript jquery arrays json

我想从JSON文件接收排序的数据。该文件如下所示(应该是有效的,已在其他网站上进行了检查):

{
    "index": 5,
    "timestamp": 1570438008,
    "data": {
        "12": [
            "Title 2",
            "Description 2"
        ],
        "10": [
            "Title 1",
            "Description 1"
        ]
    }
}

如果我现在从JS访问此JSON文件,则会得到不同于原始订单的另一条订单:

$.ajax({
    url: '../json/smiirl_data.json',
    dataType: 'json',
    success: function(response) {
        console.log(response['data']);
    }
});
JS的

console.log显示:

{
    "10": [
        "Title 1",
        "Description 1"
    ],
    "12": [
        "Title 2",
        "Description 2"
    ]
}

..但它应该看起来像这样:

{
    "12": [
        "Title 2",
        "Description 2"
    ],
    "10": [
        "Title 1",
        "Description 1"
    ]
}

0 个答案:

没有答案
相关问题