Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

JsonArray get first Object

private static int FIRST_ELEMENT = 0;

public static void main(String[] args) {
    JSONArray json = new JSONArray("[{"Hello1":"1"},{"Hello2":"2"}]");

    if (json.length() > 0) {
        System.out.println("First: " + json.getJSONObject(FIRST_ELEMENT).toString());// parse the date instead of toString()
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #JsonArray #Object
ADD COMMENT
Topic
Name
4+9 =