Extracting Keys from a JSONObject using keySet()

前端 未结 5 1623
走了就别回头了
走了就别回头了 2020-12-03 22:27

I\'m trying to extract the keys from a JSON Object. The JSON object, in this case, is obtained by making an API call to a social networking site called SkyRock and

5条回答
  •  抹茶落季
    2020-12-03 23:02

    This works for me

    o is a JSONObject -> import org.json.simple.JSONObject;

    Set s =  o.keySet();
    
        Iterator i = s.iterator();
        do{
            String k = i.next().toString();
            System.out.println(k);
    
        }while(i.hasNext());
    

提交回复
热议问题