There is my JSON-structure:
{
"date":"19.11.2013",
"parent":{
"child1":[
{
"date":"2013-11-19",
"time":"10:30",
},
{
"date":"2013-11-19",
"time":"12:20",
}
],
"child2":[
{
"date":"2013-11-19",
"time":"10:30",
},
{
"date":"2013-11-19",
"time":"12:20",
}
]
}
}
And it's my code at the moment:
public class json {
public static void main(String[] args) throws IOException, ParseException {
URL urlData = new URL("http://path.to/json");
BufferedReader reader = new BufferedReader(new InputStreamReader(
urlData.openConnection().getInputStream(), "utf-8"));
String struct = reader.readLine();
JSONParser parser = new JSONParser();
Object obj = parser.parse(struct);
JSONObject lev1 = (JSONObject) obj;
System.out.println(lev1.get("date"));
}
}
I got a date value (19.11.2013), but I don't know how to get child's values of date and time. I'm using json-simple library.