Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5947853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:01:26+00:00 2026-05-22T17:01:26+00:00

Hi I have a JSON string that looks like this: {2000:[1, 2, 3],2001:[1, 2,

  • 0

Hi I have a JSON string that looks like this:

{"2000":["1", "2", "3"],"2001":["1", "2", "3"],"2002":["1", "2", "3"]}

The string above comes from the “backend” and my JavaScript function receives the JSON string as a parameter, which is called backendData.

Looping through the parameter as below, gives the following result.

for (key in backendData) {
    alert(key);
}

Three alertboxes with the values: 2000, 2001 and 2002.

The problem is that I can’t figure out how to access the string array for each of the “parent” elements. Using syntax key[0] etc. gives me the character at index 0 in the string which in all three cases are “2”.

Help needed.

/Michael

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:01:27+00:00Added an answer on May 22, 2026 at 5:01 pm

    This loops over all the values. Remember backendData is just a javascript object.

    for (key in backendData) {
       for (x in backendData[key])
        alert(backendData[key][x]);
    }
    

    or in your example data this would work

    for (key in backendData) {
       alert(backendData[key][0];
       alert(backendData[key][1];
       alert(backendData[key][2];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSON string (from PHP's json_encode() that looks like this: [{id: 1,
I have an PHP array parsed from a JSON string that looks like this:
Hi I have a JSON string that looks like this (Usingt Rails and a
I have a Restlet Service that looks like this: @POST @Produces(application/json) public String processImmediately(String
I have a JSON string that looks something like this: {addresses:{address:[{@array:true,@id:888888,@uri:xyz,household:{@id:44444,@uri:xyz},person:{@id:,@uri:},addressType:{@id:1,@uri:xyz,name:Primary},address1:xyz,address2:null,address3:null,city:xyz,postalCode:111111}]}} What would be
Ok..so i have a json string (myJson) that looks like this: {id: 1, file:
I have an object in Javascript that looks like this function MyObject(){ this.name=; this.id=0;
I have some JSON data that looks like this: { 910719: { id: 910719,
In my aspx file, I have some code that looks like this: <script type=text/javascript>
I have a JSON response that looks like this. I want to extract the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.