Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

133
Visualizações
Visual StudioCode Intellisense after parsing Json file

My backend is built with express (so basically javascript). The backend is also able to save some data to .json files and use this data.

var data = JSON.parse(fs.readFileSync("path/data.json"));

It would help me a lot, if Visual Studio Code would provide Intellisense for my data object (like suggesting all elements of this json file). Is there any addon for this kind of "problem" ?

Example:

{
    "owner": "testperson",
    "age": "30"
}

After parsing this json file (exact way like on top), it would be very helpful to have Intellisense after writing

data. 
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There is a built-in solution in VSCode exactly that manner. To get intellisense VSCode needs to know what the type of something is and for that you can use JSDoc comments, if you want to stick to JavaScript. These are understood by VSCode without any problem. The snippet down below is applies to your given example.

/**
  * @typedef {Object} MyData
  * @property {string} owner
  * @property {number} age
*/

/**
  * @type {MyData}
*/
let data = JSON.parse(fs.readFileSync("path/data.json"));

For further reading I refer to the JSDoc docs.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda