0

my json file :

 {
   "divOne": {
     "underOne": [{
         "A": "x1",
         "B": "y1",
         "C": "z1"
       },
       {
         "A": "x2",
         "B": "y2",
         "C": "z2"
       }
     ],
     "underTwo": [{
         "A": "x3",
         "B": "y3",
         "C": "z3"
       },
       {
         "A": "x4",
         "B": "y4",
         "C": "z4"
       }
     ]
   },
   "divTwo": {
     "underThree": [{
         "A": "x5",
         "B": "y5",
         "C": "z5"
       },
       {
         "A": "x6",
         "B": "y6",
         "C": "z6"
       }
     ],
     "underFour": [{
       "A": "x7",
       "B": "y7",
       "C": "z7"
     }, {
       "A": "x8",
       "B": "y8",
       "C": "z8"
     }]
   }
 }

I want to pick "div" and then pick "under". Click button and show results A, B and C in loop.

I really search on google and tried 17 examples but I couldn't find how. I tried use javascript and jquery.

ucnumara
  • 155
  • 1
  • 1
  • 11
  • You googled and you didn't find out how to convert it to an object and cycle through its keys? – Federico klez Culloca Nov 20 '18 at 11:51
  • I'm newbie federico please be understanding – ucnumara Nov 20 '18 at 11:55
  • 1
    Ok, then first use `JSON.parse(whatever)` to parse `whatever` (which contains your json) and obtain a proper object, then check [this](https://stackoverflow.com/questions/8312459/iterate-through-object-properties) on how to iterate on object keys. Then, if you still don't know how to proceed, open a new question mentioning what you have thus far and where you got stuck. As it stands, your question is basically "write the code for me", which doesn't inspire much will to answer. Good luck with your learning process :) – Federico klez Culloca Nov 20 '18 at 11:59
  • It would probably be useful to take a good look at the structure of your data. Changing the structure of the object would make it also a lot easier to use the data. – Teun van der Wijst Nov 20 '18 at 12:02
  • you said about 17 examples, but didn't show us anyone. Please [edit] your question and add one of your tries, also explain what do you mean by `"I want to pick "div" and then pick "under""` – Calvin Nunes Nov 20 '18 at 12:37
  • @CalvinNunes Edited codes and I asked a new question. Please help me https://stackoverflow.com/questions/53407030/how-is-show-data-in-nested-array-with-jquery – ucnumara Nov 21 '18 at 08:56
  • @FedericoklezCulloca Edited codes and I asked a new question. Please take a look https://stackoverflow.com/questions/53407030/how-is-show-data-in-nested-array-with-jquery – ucnumara Nov 21 '18 at 08:57

0 Answers0