Search
 
SCRIPT & CODE EXAMPLE
 

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()
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java arraylist add 
Java :: the main of java 
Java :: What is the way to use profiles to configure the environment-specific configuration with Spring Boot? 
Java :: how to get a character in java in ascii 
Java :: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/iid/FirebaseInstanceId; 
Java :: how to compare strings java 
Java :: copying primitive array to arraylist in java 
Java :: The this(Keyword) 
Java :: java.util.HashMap has generic type parameters, please use GenericTypeIndicator instead 
Java :: java.lang.NullPointerException 
Java :: reverse number java 
Java :: setting java home 
Java :: implement stack using linked list java 
Java :: vscode code formatter cannot format 
Java :: java list last element 
Java :: destory fragment 
Java :: sort 2d array based on one column java 
Java :: do you need java installed for kafka 
Java :: add int to list java 
Java :: unchecked exception in java 
Java :: java parse json to class 
Java :: remove whitespaces 
Java :: remove last node from linked list java 
Java :: replace all these caracters in string java 
Java :: how to put a string in gradle file and acce to it android studio 
Java :: how to compute age from local date 
Java :: java sort arraylist of floats 
Java :: no of words in a string in java 
Java :: how to return the first character in an array from a method java 
Java :: isnumeric matches in java 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =