Info m = gson.fromJson(jsonString, Info.class);
for (Object ch : m.getChilds()) {
System.out.println(((Childs) ch).name);
}
JsonObject jsonObject = new JsonParser().parse(jsonString).getAsJsonObject();
JsonArray jsonArray = jsonObject.getAsJsonArray("childs");
for (int i = 0; i < jsonArray.size(); i++) {
System.out.println(jsonArray.get(i).getAsJsonObject().get("name").getAsString());
}
{
"time": "12:30",
"childs": [
{
"name": "Исмаил",
"phone": "87783866333",
"latitude": "47.090744",
"longitude": "51.917776",
"learningClass": "5"
},
{
"name": "Адель",
"phone": "87785485212",
"latitude": "47.099158",
"longitude": "51.921916",
"learningClass": "8"
}
]
}
class Info {
private String time;
private List<Childs> childs = new ArrayList<>();
public Info(String time, List<Childs> childs) {
this.time = time;
this.childs = childs;
}
String getTime() {
return time;
}
List getChilds() {
return childs;
}
}
public class Childs {
String name, phone, latitude, longitude, learningClass;
public Childs(String name, String phone, String latitude, String longitude, String learningClass) {
this.name = name;
this.phone = phone;
this.latitude = latitude;
this.longitude = longitude;
this.learningClass = learningClass;
}
}
Info m = gson.fromJson(jsonString, Info.class);
System.out.println(m.getTime()); // => 12:30
//###### как вытащить из m массив объектов childs - хз :)
switch($_SERVER['SERVER_NAME']){
case 'site1.mainsite.ru':
$db = 'dbname';
$db_login = 'login';
$db_pass = 'pass'
break;
case 'site2.mainsite.ru':
$db = 'dbname_2';
$db_login = 'login_2';
$db_pass = 'pass'
break;
}
define("SITE_URL",$site_url);
define("DB_CONN","mysql:dbname=".$dbname.";host=localhost");
define("DB_LOGIN",$db_login);
define("DB_PASS",$db_pass);