Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

353
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda