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 8242687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:15:06+00:00 2026-06-07T21:15:06+00:00

So I have this JSON struture that I have successfully passed into JS: {

  • 0

So I have this JSON struture that I have successfully passed into JS:

{
"StepOne": [
    {
        "id": "2",
        "type": "1",
        "description": "How are you feeling?",
        "options": [
            {
                "opt_id": "1",
                "opt_desc": "Good"
            },
            {
                "opt_id": "2",
                "opt_desc": "Perfect"
            },
            .... etc

It goes on until PageFive and the amount of questions vary from 1-4 in each step and the options vary from null to about 10 for each question. I want to use this information to generate a multi step form in Javascript, but I can not figure out how to access the inner data. I can only find “PageOne”, “PageTwo” etc. I am using this following code to do that:

$(document).ready(function()
    {       
        $('#show-results').click(function() 
        {
            $.post('json.php', function(data) 
            {
                var pushedData = jQuery.parseJSON(data);


                $.each(pushedData, function(i, serverData)
                {
                    alert(i);
                })
            })
        })
    });

Now I have tried these functions to get to the inner values:

var desc = pushedData.PageOne.description;

var desc = pushedData['PageOne']['Description'];

And inside the each loop I’ve tried stuff like

var desc = PageOne.description;

var desc = PageOne['description'];

It all comes out as undefined. Is there a way to iterate through each of the questions in each Page the same way I have done to iterate through the pages? And from there rinse and repeat to iterate through the options for each question? If I could access each level I should be all set for generating a poll dynamically which is the ultimate goal here.

I think this code is on to something (found out right after I posted). Not quite working though.

$(document).ready(function()
    {       
        $('#show-results').click(function() 
        {
            $.post('JSAAN.php', function(data) 
            {
                var pushedData = jQuery.parseJSON(data);

                $.each(pushedData, function(i, stepData)
                {
                    $.each(stepData, function(j, questionData)
                    {
                      // Print question here
                           $.each(questionData, function(k, optionData)
                           {
                                // Print option here
                           })

                    })
                })
            })
        })
    });
  • 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-06-07T21:15:08+00:00Added an answer on June 7, 2026 at 9:15 pm

    It needs to be

    jsonData.StepOne[0].description
    

    since you have an additional [] array wrapper.

    Depending on you structure, just omit the additional [], then you can access all the Object Properties directly, it should look like this:

    {
    "StepOne":
        {
            properties
        },
    "StepTwo":
        {
            properties
        }
    }
    

    however, it’s okay to have such a structure – now you have to write StepOne[x].prop

    "StepOne":[
        {
            properties
        },
        {
            other props
        }],
     "StepTwo":[{...
    

    According to the code you posted, this might be what you want, since you have several questions per step(?).

    The simple loop looks like the following:

    for (var key in o) {
      if (o.hasOwnProperty(key)) {
        console.log(key + " -> " + o[key]);
      }
    }
    

    A nested loop is more complicated though:

    function loop(obj) {
        $.each(obj, function(key, val) {
            if($.isPlainObject(val) || $.isArray(val)) {
    
                console.log(key + " is an Object");
                // object or array -> call recursively
                loop(val);
    
            } else {
               // plain value
               console.log(key + "->" + val);
            }
        });
    }
    

    Take a look at this example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a json structure that looks something like this: list:[ { type:link, href:http://google.com
I have this JSON http://www.progmic.com/ielts/retrive.php that I need to parse. When I do it
I have this XML structure that I wish to construct in JSON format using
I have a json structure that I'm decoding that looks like this: person =>
I have a web service class that successfully pulls my JSON from a feed
I have a JSON tree structure that is generated dinamically, this means the keys
I have a hash that I'm getting from using JSON.parse. I am inserting into
I have some data and need to create a json file with this structure
i have this JSON object: {error:null, result:[{id:1234567890, count:1, recipients: [u3848, u8958, u7477474 ], dateCreated:2012-06-13T09:13:45.989Z
I have this JSON (which validates according to JSONLint ): [ { "BugCount":"2", "BugTitle":"C:\\INETPUB\\WWWROOT\\CLUBREADY2\\TRAINERS\\../Connections/LTC.asp",

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.