The structure I am currently working with is as follows;
import data from "../data.min.json";
export enum TileType {
tree = 'tree',
rock = 'rock'
}
interface MapTile {
walkable: boolean;
positions: number[][];
}
export type MapTiles = {
[key in TileType]: MapTile
}
export interface Level1 {
mapTiles: MapTiles;
}
export interface RootObject {
level_1: Level1;
}
export default data as RootObject;
Everything seems to be functioning correctly. However, I encountered an issue when trying to implement it in the following way;
const entries = Object.entries(data.level_1.mapTiles);
entries.forEach(([tileType, data]) => {
})
Instead of receiving the Enum value, 'tileType' holds a string. How can I access the Enum value instead?
Here is an overview of the data structure being used:
{
"level_1": {
"mapTiles": {
"tree": {
"walkable": false,
"positions": [
[ 0, 0 ], [ 0, 40 ], [ 0, 80 ]
]
},
"rock": {
"walkable": false,
"positions": [
[2, 4], [5, 7]
]
},
}
}
}