use of net.sf.json.JSONArray in project cachecloud by sohutv.
the class AppController method assembleGroupJson.
/**
* AppCommandGroup列表组装成json串
*/
private String assembleGroupJson(List<AppCommandGroup> appCommandGroupList) {
if (appCommandGroupList == null || appCommandGroupList.isEmpty()) {
return "[]";
}
List<SimpleChartData> list = new ArrayList<SimpleChartData>();
for (AppCommandGroup appCommandGroup : appCommandGroupList) {
SimpleChartData chartData = SimpleChartData.getFromAppCommandGroup(appCommandGroup);
list.add(chartData);
}
JSONArray jsonArray = JSONArray.fromObject(list);
return jsonArray.toString();
}
use of net.sf.json.JSONArray in project zaproxy by zaproxy.
the class StandardParameterParser method init.
@Override
public void init(String config) {
try {
JSONObject json = JSONObject.fromObject(config);
this.setKeyValuePairSeparators(json.getString(CONFIG_KV_PAIR_SEPARATORS));
this.setKeyValueSeparators(json.getString(CONFIG_KV_SEPARATORS));
JSONArray ja = json.getJSONArray(CONFIG_STRUCTURAL_PARAMS);
for (Object obj : ja.toArray()) {
this.structuralParameters.add(obj.toString());
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
use of net.sf.json.JSONArray in project zaproxy by zaproxy.
the class StandardParameterParser method getConfig.
@Override
public String getConfig() {
JSONObject json = new JSONObject();
json.put(CONFIG_KV_PAIR_SEPARATORS, this.getKeyValuePairSeparators());
json.put(CONFIG_KV_SEPARATORS, this.getKeyValueSeparators());
JSONArray ja = new JSONArray();
ja.addAll(this.structuralParameters);
json.put(CONFIG_STRUCTURAL_PARAMS, ja);
return json.toString();
}
use of net.sf.json.JSONArray in project FilmGoGo by cajet.
the class ReaddataFromAPI method main.
public static void main(String[] args) {
initTable();
/*------------------------获取正在上映的电影列表的API,插入电影数据-----------------------*/
String url_movie = "http://m.maoyan.com/movie/list.json";
String json_movie = loadJson(url_movie);
JSONObject jsonObject = JSONObject.fromObject(json_movie);
JSONArray array = jsonObject.getJSONObject("data").getJSONArray("movies");
String insert_movie;
JSONObject subObject;
for (int i = 0; i < array.size(); i++) {
subObject = array.getJSONObject(i);
insert_movie = "insert into movie(name, type, description, image, apiid) values('" + subObject.get("nm") + "','" + subObject.get("cat") + "','" + subObject.get("scm") + "','" + subObject.get("img") + "','" + subObject.get("id") + "');";
loadDatatoDB(insert_movie);
}
/*------------------------获取正在上映的电影简介的API,插入电影简介数据-----------------------*/
String find_movies_id = "select * from movie";
try {
con = DriverManager.getConnection(dburl, user, pass);
con.setAutoCommit(false);
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(find_movies_id);
while (rs.next()) {
String url_description = "http://m.maoyan.com/movie/" + rs.getString(5) + ".json";
String json_description = loadJson(url_description);
jsonObject = JSONObject.fromObject(json_description);
String temp = (String) jsonObject.getJSONObject("data").getJSONObject("MovieDetailModel").get("dra");
//System.out.println(temp);
String insert_description = "update movie set description = ? where apiid= ?";
PreparedStatement pst = con.prepareStatement(insert_description);
pst.setString(1, temp);
pst.setString(2, rs.getString(5));
pst.executeUpdate();
con.commit();
}
} catch (Exception e) {
System.out.println(e);
}
/*------------------------获取获取周边影院的API,插入影院数据-----------------------*/
String url_cinema = "http://m.maoyan.com/cinemas.json";
String json_cinema = loadJson(url_cinema);
JSONObject jsonObject2 = JSONObject.fromObject(json_cinema);
JSONArray array2 = jsonObject2.getJSONObject("data").getJSONArray("番禺区");
String insert_cinema;
JSONObject subObject2;
for (int i = 0; i < array2.size(); i++) {
subObject2 = array2.getJSONObject(i);
insert_cinema = "insert into cinema(name, address, city, area, apiid) values('" + subObject2.get("nm") + "','" + subObject2.get("addr") + "','广州','" + subObject2.get("area") + "','" + subObject2.get("id") + "');";
loadDatatoDB(insert_cinema);
}
/*-------------------------获取场次的API,插入showtime数据库-----------------------*/
/*ArrayList<String> movies_array= getMoviesID();
ArrayList<String> cinema_array= getCinemasID();
for (int i= 0; i< movies_array.size(); i++) {
for (int j= 0; j< cinema_array.size(); j++) {
String url_showtime= "http://m.maoyan.com/showtime/wrap.json?cinemaid="+cinema_array.get(j)+"&movieid="+movies_array.get(i);
System.out.println(url_showtime);
String json_showtime= loadJson(url_showtime);
JSONObject jsonObject3= JSONObject.fromObject(json_showtime);
load_showtime_TodayandTomorrow(jsonObject3, movies_array.get(i), cinema_array.get(j));
}
}*/
/*------------------------获取座位情况的API,插入seat数据库--------------------------*/
/*ArrayList<String> showtimes_array= getShowtimeID();
//获取今天和明天的日期
Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH)+1;
int day = c.get(Calendar.DAY_OF_MONTH)+1;
int day2= c.get(Calendar.DAY_OF_MONTH);
String day_str= "-"+day;
String day2_str= "-"+day2;
String month_str= "-"+month;
if (month< 10) month_str= "-0"+month;
if (day< 10) day_str= "-0"+day;
if (day2< 10) day2_str= "-0"+day2;
String tomorrow= year+month_str+day_str;
String today= year+month_str+day2_str;
//载入今天的座位
for (int i= 0; i< showtimes_array.size(); i++) {
String url_seat_today= "http://m.maoyan.com/show/seats?showId="+showtimes_array.get(i)+"&showDate="+today;
System.out.println(url_seat_today);
String json_seat= loadJson(url_seat_today);
JSONObject jsonObject4= JSONObject.fromObject(json_seat);
load_seat_TodayandTomorrow(jsonObject4, showtimes_array.get(i));
}
//载入明天的座位
for (int i= 0; i< showtimes_array.size(); i++) {
String url_seat_tomorrow= "http://m.maoyan.com/show/seats?showId="+showtimes_array.get(i)+"&showDate="+tomorrow;
System.out.println(url_seat_tomorrow);
String json_seat= loadJson(url_seat_tomorrow);
JSONObject jsonObject4= JSONObject.fromObject(json_seat);
load_seat_TodayandTomorrow(jsonObject4, showtimes_array.get(i));
}
*/
}
use of net.sf.json.JSONArray in project compiler by boalang.
the class RepoMetadata method toBoaMetaDataJson.
public JSONObject toBoaMetaDataJson() {
JSONObject jsonRepo = new JSONObject();
jsonRepo.put(ID, id);
jsonRepo.put(NAME, name);
jsonRepo.put(CREATED_TIMESTAMP, created_timestamp);
jsonRepo.put(SUMMARY_PAGE, summaryPage);
jsonRepo.put(HOME_PAGE, homepage);
jsonRepo.put(DESCRIPTION, description);
if (programmingLanguages != null) {
JSONArray langs = new JSONArray();
for (String lang : programmingLanguages) langs.add(lang);
jsonRepo.put(PROGRAMMING_LANGUAGES, langs);
}
if (gitRepository != null) {
JSONObject jsonGit = new JSONObject();
jsonGit.put("location", gitRepository);
jsonRepo.put(GIT_REPO, jsonGit);
}
JSONObject jo = new JSONObject();
jo.put("Project", jsonRepo);
return jo;
}
Aggregations