15 Typescript (3) json ..

 Credits


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

Entradas populares de este blog

14 Typescript (2) with jquery, bootstrap and other module stuff

11. TypeScript (1) recap with "Makigas"

04. Download (Files, Streams...). Show PDFs. Anchor problem, Iframes