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

201
Views
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
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!