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

197
Vistas
Teleport API: Access JSON Object properties

I am learning some things about API calls in Javascript. For this, I make a call to the teleport api.

From there I get an Json object back. Now I would like to access the link which you can see in the "json object" below.

_embedded
    city:search-results     [25]
    0
    _links
    city:item
    href:   https://api.teleport.org/api/cities/geonameid:2661552/
    

I have a problem with the "city:search-results" key, because I cant use a the ":" in the dotted notation.

so, how can I get the href value?

I hope its understandable, im sorry for the bad explanation. Thanks for your help!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I see how the JSON is returned. For this example, use bracket notation for city:search-results as

_embedded["city:search-results"][0]

And for accessing the href property:

_embedded["city:search-results"][0]["_links"]["city:item"]["href"]

Example code (with 2 city:search-results objects):

var _embedded = {
  "city:search-results": [{
      "_links": {
        "city:item": {
          "href": "https://api.teleport.org/api/cities/geonameid:1796236/"
        }
      },
      "matching_alternate_names": [],
      "matching_full_name": "Shanghai, Shanghai, China"
    },
    {
      "_links": {
        "city:item": {
          "href": "https://api.teleport.org/api/cities/geonameid:745044/"
        }
      },
      "matching_alternate_names": [],
      "matching_full_name": "Istanbul, Istanbul, Turkey"
    }
  ]
};
console.log(_embedded["city:search-results"][0]["_links"]["city:item"]["href"]);

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