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

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

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 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