15 Typescript (3) json ..
Credits
- Makigas
- Ariel Bautista
- Academind
- Peter Lehnhhardt (Stack Overflow)
- Jurgen Van Moere-Understanding Modules
- Neoguias-webapck
Swashbuckling with Code (webpack & ts)
npm install lite-server --save-dev
package.json -> "scripts":[ .... "start":"lite-server"
Find index.html
in tsconfig,json
"resolveJsonModule": true,
json data (menu.json)
[
{"key":"hola", "translation": ["hola", "hola","hello","Hallo"]},
{"key":"now", "translation": ["ahora", "ara","now","alssecspiken"]}
]
a module for reading json (index.ts)
import menu from "../data-i18n/i18n-menu.json"
import field from "../data-i18n/i18n-field.json"
console.log(menu[0].key);
console.log(menu[0].translation[0]);
console.log(menu[1].key);
console.log(menu[1].translation[1]);
Comentarios
Publicar un comentario