Mẫu cấu hình JSON và hàm JavaScript minh họa cấu trúc dữ liệu trò chơi tại 88VV.
{ } gameCatalog.js{ } gameCatalog.json
Sao chép mã
JavaScript
// Cấu hình danh mục trò chơi nổ hũ 88VV cục bộ
const localGameCatalog = {
platform: "88VV" ,
country: "vn" ,
supportedCategory: "Nổ hũ" ,
games: [
{ id: "192" , name: "Funky Fortunez" , category: "Nổ hũ" },
{ id: "143" , name: "Wild Heist Co" , category: "Nổ hũ" },
{ id: "083" , name: "Fortune Ox" , category: "Nổ hũ" },
{ id: "141" , name: "Ninja Raccoon" , category: "Nổ hũ" },
{ id: "190" , name: "Mayan Destiny" , category: "Nổ hũ" }
]
};
function getGameInfo(gameId) {
return localGameCatalog.games.find(item => item.id === gameId) || null ;
}
// Kiểm tra thông tin trò chơi Fortune Ox
const selectedGame = getGameInfo("083" );
console.log(selectedGame.name); JSON
{
"platform" : "88VV" ,
"country" : "vn" ,
"supportedCategory" : "Nổ hũ" ,
"games" : [
{
"id" : "192" ,
"name" : "Funky Fortunez" ,
"category" : "Nổ hũ"
},
{
"id" : "143" ,
"name" : "Wild Heist Co" ,
"category" : "Nổ hũ"
},
{
"id" : "083" ,
"name" : "Fortune Ox" ,
"category" : "Nổ hũ"
},
{
"id" : "141" ,
"name" : "Ninja Raccoon" ,
"category" : "Nổ hũ"
},
{
"id" : "190" ,
"name" : "Mayan Destiny" ,
"category" : "Nổ hũ"
}
]
}