Property Names From JsonObject

Here is a quick snippet for finding the property names of an com.google.gson.JsonObject.

Set<Map.Entry<String, JsonElement>> map = myJObj.entrySet();
Iterator<Map.Entry<String, JsonElement>> iterator = map.iterator();
int size = map.size();for( int k = 0; k < size; k++ )
 {
        // .getKey() returns the name of the property
        String key = iterator.next().getKey();
        iterator.remove();
}
Posted in Java | Tagged , , | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>