Я пытаюсь показать все из API в Datatable JS. Моя структура API выглядит как
{
"Success": {
"Meta": {
"Id": "124578828",
"Action": "ItemList",
"Type": "Item"
},
"Body": {
"TotalItems": 18,
"Item": [
{
"Category": "Clothing",
"ItemId": 12354,
"Attributes": {
"name": "Tee 1",
"brand": "Brand 2",
"material_type": "Cotton",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."
},
"Skus": [
{
"Status": "active",
"stock": 20,
"Images": [
"images/tee1_01.jpg",
"images/tee1_02.jpg",
"images/tee1_03.jpg",
"",
"",
"",
"",
""
],
"Sku": "TEE-001233",
"Url": "#",
"price": 20,
"Available": 12
}
]
}
]
}
}
}
Попытка показать элемент Success.Body.Item []. Attributes.name, Success.Body.Item []. Attributes.brand, Success.Body.Item [] .Skus []. Images [0] & Success.Body.Item []. Skus []. Цена в столбцах
<script>
$(document).ready(function() {
$('#data-table').DataTable({
"ajax": "GetProducts.json",
"columns": [{
"data": "Success.Body.Item[].Attributes.name"
},
{
"data": "Success.Body.Item[].Attributes.brand"
},
{
"data": "Success.Body.Item[].Skus[].Images[0]"
},
{
"data": "Success.Body.Item[].Skus[].price"
}
]
});
});
</script>