-1
{
"ResponseType": "success",
"ResponseMessage": "success",
"Personal Preference": [
{
  "Questionno": 3,
  "TokenKey": "150920150252340989472d8d09fc6563",
  "QuestionText": "Km per jaar",
  "QuestionType": "Slider",
  "QuestionOrder": 3,
  "answerOptionList": [],
  "Answer": "16014",
  "Unit": "KM",
  "Minimum": 1,
  "Maximum": 100000,
  "SliderOptionList": [
    "<1000",
    "1000-1500",
    "1501-2000",
    "2001-3000",
    "3001-5000",
    ">5000"
  ]

The above is the JSON which i receive from the server using Volley. I need to get only the Keys(ResponseType, ResponseMessage, Personal Preference: these might varry) from this JSON and store in an array.

mrnobody
  • 409
  • 2
  • 8
  • 16

1 Answers1

1

Use this code

Iterator iterator   = jsonObject.keys();
List<String> keysList = new ArrayList<String>();
while(iterator.hasNext()) {
    String key = (String) iterator.next();
    keysList.add(key);
}
Ajinkya
  • 1,057
  • 7
  • 18