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

346
Visualizações
Get value of json file in javascript(nodejs)

So i want to get a value from a json file, but for the life of it, i cant get to understand what to write.

So if someone could help me write this line of code in javascript node, i would be grateful. I am trying to get the value of "totalCount"

This is from a library called GeoDb just for context.

main.js(NODEjs)

const timezone = require("./TimezonePortugal.json"); //referencing the json

console.log(timezone.metadata); // i dont know what to say afther this

TimezonePortugal.json

{"data":[{"code":"EUR","countryCodes":["PT","YT","IE","AD","IT","AT","RE","AX","BE","BL","SI","SK","SM","CY","DE","LT","LU","LV","MC","ME","MF","EE","MQ","MT","VA","ES","NL","FI","FR","GF","GP","GR","PM"],"symbol":"€"}],"metadata":{"currentOffset":0,"totalCount":1}}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

"." means inside. If you want to get value of totalCount you have to think like this:

timezone.metadata.totalCount = totalCount inside the metada, metadata inside the timezone

For example:

var timezone=
{
      "data":[
               {
                  "code":"EUR",
                  "countryCodes": ["PT","YT",],
                  "symbol":"€"
                }
              ],
  "metadata": {
                "currentOffset":0,
                "totalCount":1
               }
}
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