Search in sources :

Example 26 with JSONArray

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();
}
Also used : ArrayList(java.util.ArrayList) JSONArray(net.sf.json.JSONArray) SimpleChartData(com.sohu.cache.web.chart.model.SimpleChartData)

Example 27 with JSONArray

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);
    }
}
Also used : JSONObject(net.sf.json.JSONObject) JSONArray(net.sf.json.JSONArray) JSONObject(net.sf.json.JSONObject) PatternSyntaxException(java.util.regex.PatternSyntaxException) URIException(org.apache.commons.httpclient.URIException) InvalidParameterException(java.security.InvalidParameterException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 28 with JSONArray

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();
}
Also used : JSONObject(net.sf.json.JSONObject) JSONArray(net.sf.json.JSONArray)

Example 29 with JSONArray

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));
		}
		*/
}
Also used : JSONObject(net.sf.json.JSONObject) JSONArray(net.sf.json.JSONArray) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 30 with JSONArray

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;
}
Also used : JSONObject(net.sf.json.JSONObject) JSONArray(net.sf.json.JSONArray)

Aggregations

JSONArray (net.sf.json.JSONArray)31 JSONObject (net.sf.json.JSONObject)19 ArrayList (java.util.ArrayList)9 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 Map (java.util.Map)5 CobarAdapterDAO (com.alibaba.cobar.manager.dao.CobarAdapterDAO)4 Test (org.junit.Test)4 CommandStatus (com.alibaba.cobar.manager.dataobject.cobarnode.CommandStatus)3 ProcessorStatus (com.alibaba.cobar.manager.dataobject.cobarnode.ProcessorStatus)3 SimpleChartData (com.sohu.cache.web.chart.model.SimpleChartData)3 ParameterDefinition (hudson.model.ParameterDefinition)3 ParameterValue (hudson.model.ParameterValue)3 OutputStream (java.io.OutputStream)3 CobarDO (com.alibaba.cobar.manager.dataobject.xml.CobarDO)2 Pair (com.alibaba.cobar.manager.util.Pair)2 PluginTestVerifier (com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)2 Method (java.lang.reflect.Method)2 ParseException (java.text.ParseException)2 Iterator (java.util.Iterator)2