Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!