Answers for "get first element from json object"

0

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()
    }
}
Posted by: Guest on January-11-2021
0

get top items from json object

var top10 = data.sort(function(a, b) { return a.Variable1 < b.Variable1 ? 1 : -1; })
                .slice(0, 10);
Posted by: Guest on July-15-2020

Code answers related to "get first element from json object"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language