Created
May 24, 2017 04:23
-
-
Save clucle/940636bdad2d18fbbc0d9da230d57e76 to your computer and use it in GitHub Desktop.
JSON Array Parsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.json.simple.JSONArray; | |
import org.json.simple.JSONObject; | |
import org.json.simple.parser.JSONParser; | |
public class Main { | |
public static void main(String[] args) { | |
String str = "[{'json_type_1'},{'json_type_2'},{'json_type_3'}]" | |
JSONParser parser = new JSONParser(); | |
JSONArray jsonArray = new JSONArray(); | |
try { | |
jsonArray = (JSONArray) parser.parse(str); | |
} catch (Exception e) { | |
System.out.println(e.toString()); | |
} | |
for (int indexJson = 0; indexJson < jsonArray.size(); indexJson++) { | |
JSONObject obj = (JSONObject) jsonArray.get(indexJson); | |
System.out.println(obj.get("endTime").toString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment