0

I have pulled in some JSON data in to JS that has nested data.

So to get to the data required I have

jsondata.tree[0]

Based on a users click of a button, I want to be able to get a particular piece of content, ie

jsondata.tree[0]["true"][0], which traverses me into another array.

What I want to be able to do is to concatenate on to 'jsondata.tree[0]' for example jsondata.tree[0] + ["true"][0] + ["false"][0] + ["true"][0]

to form:

var returnedData = jsondata.tree[0]["true"][0]["false"][0]["true"][0];

Is this possible please?



    //JS
    //==============
    var jqxhr = $.getJSON( "js/content.json", function() {
        // console.log( "success" );
    })


    .done(function( data ) {
        var dat = data.tree[0]
        $("button").on("click", function(e){
        // Here I want to add '["true'][0]' to 'data.tree[0]' to return the next question, and so on eg. data.tree[0]["true'][0]["true'][0]
    });

    })





LeeBoy
  • 1

0 Answers0