how to parse a JSON object --JavaScript

Hello ,
  I have complex json object that I need some help to parse..

I want all the QE elements value
e.g

Id = 21,
Label =First Name,
Value = FNl
-----------------
 Id:= 22,
Label = Last Name
Value": LN

[
  {
    "CanAdd": false,
    "QG": [
      {
        "Id": 3,
        "Name": "Name",
        "Q": [
          {
            "Id": 1,
            "Name": "First Name",
            "QE": [
              {
                "Id": 21,
                "Label": "First Name",
                "Value": FN
              }
            ],
            "Version": "1",
            "Display": false
          },
          {
            "Id": 2,
            "Name": "Last Name",
            "QE": [
              {
                "Id": 22,
                "Label": "Last Name",
                "Value": LN
              }
            ],
            "Version": "1",
            "Display": false
          }
        ],
        "Version": "1",
        "Display": false
      }
    ]
  },
  {
    "CanAdd": false,
    "QG": [
      {
        "Id": 30,
        "Name": "address",
        "Q": [
          {
            "Id": 1,
            "Name": "address",
            "QE": [
              {
                "Id": 21,
                "Label": "address1",
                "Value": AD1
              }
            ],
            "Version": "1",
            "Display": false
          }
        ],
        "Version": "1",
        "Display": false
      }
    ]
  },
  {
    "CanAdd": false,
    "QG": [
      {
        "Id": 30,
        "Name": "phone",
        "Q": [
          {
            "Id": 1,
            "Name": "phone1",
            "QE": [
              {
                "Id": 21,
                "Label": "phone1",
                "Value": PH1
              }
            ],
            "Version": "1",
            "Display": false
          }
        ],
        "Version": "1",
        "Display": false
      }
    ]
  }
]

                                  

Open in new window

chand pbAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
Try:
function getQE() {
    var QE=[];
    for (var i=0;i<json.length;i++) {
        for(var j=0;j<json[i].QG.length;j++) {
              for(var k=0;k<json[i].QG[j].Q.length;k++) {
                     for(var l=0; l<json[i].QG[j].Q[k].QE.length; l++){
                            QE[QE.length]=json[i].QG[j].Q[k].QE[l];
                      }
              }
         }
    }
return QE;
}

Open in new window

0
RobOwner (Aidellio)Commented:
Can be simplified to this (http://jsbin.com/rehipi/1/edit?js,console)

var QE_Values = [];
for (var a in j) {
  var i = j[a].QG[0].Q;
  for (var b in i) {
    QE_Values.push(i[b].QE);
  }
}
console.dir(QE_Values);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.