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

295
Views
Can't access variables of JSON response from REST-API in Javascript

I have a problem getting access to the variables in a JSON-File. I get the file as a response from a REST-API. Here you can see the JSON-File:

{
"_embedded": {
    "events": [
        {
            "name": "Josh.",
            "type": "event",
            "id": "Z698xZC2Z17CebP",
            "test": false,
            "url": "https://www.ticketmaster.de/event/josh-tickets/382625?language=en-us",
            "locale": "en-us"

I want to access the value (Josh) of the "name" variable in Javascript in line number 5 and store it into a new variable to use it later.

This ist how I try to do it:

var = data._embedded.events[0].name

But I can't get access to the value attached to "name".

I have read the answers to similar questions here, but there was no solution for me.

I have only read, that it does not work because of the wrong JSON-structure. In other threads, they say there has to be a "{" instead of a "[" in line 3. But I don't know how to change it in javascript directly. I tried it with the JSON.stringify()-method but it didn't work out.

Can somebody help me, please? Is there any way to get access?

I hope you can understand my problem.

Thank you very much!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It seems that your json structure has some errors. The json structure similar to the following is legal. Of course, it is no problem to use a legal structure to exec data._embedded.events[0].name.

const data = {
  "_embedded": {
      "events": [
          {
              "name": "Josh.",
              "type": "event",
              "id": "Z698xZC2Z17CebP",
              "test": false,
              "url": "https://www.ticketmaster.de/event/josh-tickets/382625?language=en-us",
              "locale": "en-us"
          },
          {
              "name": "Josh.",
              "type": "event",
              "id": "Z698xZC2Z17CebP",
              "test": false,
              "url": "https://www.ticketmaster.de/event/josh-tickets/382625?language=en-us",
              "locale": "en-us"
          },
          //...
      ]
   }
}

console.log(data._embedded.events[0].name)

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!