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

206
Vistas
Javascript: Cannot get json node by name with JSON.parse()

I have an vb.net like the next:

Public Shared Function GetCountries()

    Dim lCheckOutManager As CheckOutManager = CType(HttpContext.Current.Session("CHECKOUT_MANAGER"), CheckOutManager)
    Dim dataResult = lCheckOutManager.getCountries()
    Return JsonConvert.SerializeObject(dataResult, Formatting.Indented)

End Function

Which returns a Json object to javascript like the next:

[
   {
      "ID":12,
      "NAME":"Canada",
      "INCOTERM":3
   },
   {
      "ID":60,
      "NAME":"United States",
      "INCOTERM":3
   }
]

And as I'm needing to join two json in the response and be able to access them separately, I did a little modification to my method like this:

Public Shared Function GetCountries()

    Dim lCheckOutManager As CheckOutManager = CType(HttpContext.Current.Session("CHECKOUT_MANAGER"), CheckOutManager)

    Dim dataResult = lCheckOutManager.getCountries()
    Dim strDataResult As String = "{Countries:" & JsonConvert.SerializeObject(dataResult, Formatting.Indented) & "}"

    Return JsonConvert.SerializeObject(strDataResult, Formatting.Indented)

End Function

So I can identify the first json by the node "Countries" (and then I will concatenate the second JSON), so I get a json like the next:

{
   "Countries":[
      {
         "ID":12,
         "NAME":"Canada",
         "INCOTERM":3
      },
      {
         "ID":60,
         "NAME":"United States",
         "INCOTERM":3
      }
   ]
}

But all my attempts to retrieve the "Countries" node are

being unsuccessful. Iv'e tried:

JSON.parse(results[0].d).Countries, JSON.parse(results[0].d)["Countries"], JSON.parse(results[0].d)[0], Object.keys(JSON.parse(results[0].d))[0] but none of them works, as they end in undefined or empty strings.

Any help?

about 4 years ago · Juan Pablo Isaza
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