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
The javadoc says:
public interface JsonObject
extends JsonStructure, Map
So, a JSONObject is a Map whose keys are of type String
, and whose values are of type JSONValue
.
And the javadoc of Map
Set keySet()
Returns a Set view of the keys contained in this map
So, what JSONObject.keySet()
returns is a Set
(which is quite logical, since keys of JSON objects are strings).
So all that you want is:
Set keys = posts.keySet();