当前位置: 首页>>代码示例>>Java>>正文


Java JsonArray.add方法代码示例

本文整理汇总了Java中com.eclipsesource.json.JsonArray.add方法的典型用法代码示例。如果您正苦于以下问题:Java JsonArray.add方法的具体用法?Java JsonArray.add怎么用?Java JsonArray.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.eclipsesource.json.JsonArray的用法示例。


在下文中一共展示了JsonArray.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setValidTypeJsonArray

import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
/**
 * asigna valores JSON validos a un jsonArray
 * @param cellRef
 * @param jsonArray
 * @param value
 */
private void setValidTypeJsonArray(String cellRef,JsonArray jsonArray, String value)
{
	int jsonValidType = jsonValidType(value);
	
	if(jsonValidType == JSON_STRING)
	{
		
		jsonArray.add(value);
	}
	else if(jsonValidType == JSON_NUMBER)
	{
		jsonArray.add(Double.parseDouble(value));
	}
	else if(jsonValidType == JSON_BOOLEAN)
	{
		jsonArray.add(Boolean.getBoolean(value));
	}
	else
	{
		jsonArray.add(value);
	}
	
}
 
开发者ID:rodrigoEclipsa,项目名称:excelToApp,代码行数:30,代码来源:ExcelManager.java

示例2: makeJSONObject

import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
public JsonObject makeJSONObject() {
    JsonObject json = new JsonObject();
    try {
        json.add(OPERATION_NAME, operationName);
        json.add(OPERATION_NO, operationNumber);
        json.add(CALENDER_ID, calenderID);
        JsonArray array = new JsonArray();
        for (int i = 0; i < trip.size(); i++) {
            JsonObject obj = new JsonObject();
            obj.add(TRIP_ID, jpti.indexOf(trip.get(i)));
            array.add(obj);
        }
        json.add(TRIP_LIST, array);
        return json;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return new JsonObject();
}
 
开发者ID:KameLong,项目名称:AOdia,代码行数:20,代码来源:Operation.java

示例3: doGet

import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
@Override
public ModelAndView doGet(IHTTPSession session) {
	ModelAndView result = new ModelAndView();
	JsonArray array = new JsonArray();
	for (Entry<String, Metric> cur : ru.r2cloud.metrics.Metrics.REGISTRY.getMetrics().entrySet()) {
		JsonObject curObject = new JsonObject();
		curObject.add("id", cur.getKey());
		curObject.add("url", "/admin/static/rrd/" + cur.getKey() + ".rrd");
		if (cur.getValue() instanceof FormattedCounter) {
			curObject.add("format", ((FormattedCounter) cur.getValue()).getFormat().toString());
		}
		if (cur.getValue() instanceof FormattedGauge<?>) {
			curObject.add("format", ((FormattedGauge<?>) cur.getValue()).getFormat().toString());
		}
		array.add(curObject);
	}
	result.setData(array.toString());
	return result;
}
 
开发者ID:dernasherbrezon,项目名称:r2cloud,代码行数:20,代码来源:Metrics.java

示例4: doGet

import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
@Override
public ModelAndView doGet(IHTTPSession session) {
	ModelAndView result = new ModelAndView();
	JsonObject entity = new JsonObject();
	Long lastUpdateMillis = config.getLong("satellites.tle.lastupdateAtMillis");
	if (lastUpdateMillis != null) {
		entity.add("lastUpdated", lastUpdateMillis);
	}
	JsonArray tle = new JsonArray();
	for (Entry<String, ru.r2cloud.model.TLE> cur : service.findAll().entrySet()) {
		JsonObject curTle = new JsonObject();
		curTle.add("id", cur.getKey());
		JsonArray curData = new JsonArray();
		for (String curDataEntry : cur.getValue().getRaw()) {
			curData.add(curDataEntry);
		}
		curTle.add("data", curData);
		tle.add(curTle);
	}
	entity.add("tle", tle);
	result.setData(entity.toString());
	return result;
}
 
开发者ID:dernasherbrezon,项目名称:r2cloud,代码行数:24,代码来源:TLE.java

示例5: doGet

import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
@Override
public ModelAndView doGet(IHTTPSession session) {
	ModelAndView result = new ModelAndView();
	JsonArray array = (JsonArray) Json.array();
	for (Airplane cur : dao.getAirplanes()) {
		JsonArray positions = (JsonArray) Json.array();
		if (cur.getPositions() != null) {
			for (Position curPosition : cur.getPositions()) {
				positions.add(Json.object().add("lng", curPosition.getLongitude()).add("lat", curPosition.getLatitude()));
			}
		}
		array.add(Json.object().add("icao24", cur.getIcao24()).add("positions", positions));
	}
	result.setData(array.toString());
	return result;
}
 
开发者ID:dernasherbrezon,项目名称:r2cloud,代码行数:17,代码来源:ADSB.java

示例6: doGet

import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
@Override
public ModelAndView doGet(IHTTPSession session) {
	ModelAndView result = new ModelAndView();
	JsonObject entity = new JsonObject();
	entity.add("domain", acmeClient.getSslDomain());
	entity.add("enabled", acmeClient.isSSLEnabled());
	entity.add("running", acmeClient.isRunning());
	entity.add("agreeWithToC", acmeClient.isSSLEnabled() || acmeClient.isRunning());
	JsonArray messages = new JsonArray();
	for (String cur : acmeClient.getMessages()) {
		JsonObject curObject = new JsonObject();
		curObject.add("message", cur);
		messages.add(curObject);
	}
	entity.add("log", messages);
	result.setData(entity.toString());
	return result;
}
 
开发者ID:dernasherbrezon,项目名称:r2cloud,代码行数:19,代码来源:SSL.java

示例7: makeJSONObject

import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
public JsonObject makeJSONObject(){
    JsonObject json=new JsonObject();
    try{
        json.add(AGENCY_ID,agencyID);
        if(number >-1){
            json.add(NO, number);
        }
        json.add(NAME,name);
        if(nickName.length()>0){
            json.add(NICKNAME,nickName);
        }
        if(description.length()>0){
            json.add(DESCRIPTION,description);
        }
        if(type>0&&type<13){
            json.add(TYPE,type);
        }
        if(url.length()>0){
            json.add(URL,url);
        }
        if(color!=null){
            json.add(COLOR,color.getHTMLColor());
        }
        if(textColor!=null){
            json.add(TEXT_COLOR,textColor.getHTMLColor());
        }
        JsonArray stationArray=new JsonArray();
        for(RouteStation station:stationList){
            stationArray.add(station.makeJSONObject());
        }
        json.add(STATION,stationArray);

    }catch(Exception e){
        e.printStackTrace();
    }
    return json;
}
 
开发者ID:KameLong,项目名称:AOdia,代码行数:38,代码来源:Route.java

示例8: makeStopsListJSON

import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
private JsonArray makeStopsListJSON(){
    JsonArray array=new JsonArray();
    for(Stop stop:stops){
        array.add(jpti.indexOf(stop));
    }
    return array;
}
 
开发者ID:KameLong,项目名称:AOdia,代码行数:8,代码来源:Station.java

示例9: makeJSONObject

import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
public JsonObject makeJSONObject(){
    JsonObject json=new JsonObject();
    try{
        if(name.length()>0) {
            json.add(NAME, name);
        }
        if(number.length()>0) {
            json.add(NUMBER, number);
        }
        json.add(DIRECTION,direction);
        json.add(CLASS,jpti.indexOf(traihType));
        json.add(BLOCK,blockID);
        json.add(CALENDER,calender.index());
        json.add(ROUTE,jpti.indexOf(route));
        if(extraCalendarID>-1){
            json.add(EXTRA_CALENDER,extraCalendarID);
        }
        JsonArray timeArray=new JsonArray();
        for(Time time:timeList.values()){
            timeArray.add(time.makeJSONObject());
        }
        json.add(TIME,timeArray);


    }catch(Exception e){
        e.printStackTrace();
    }
    return json;
}
 
开发者ID:KameLong,项目名称:AOdia,代码行数:30,代码来源:Trip.java

示例10: makeJSONObject

import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
public JsonObject makeJSONObject(){
    try{
        JsonObject json=new JsonObject();
        json.add(DIRECT,direct);
        if(name.length()>0){
            json.add(NAME,name);
        }
        if(number.length()>0){
            json.add(NUMBER,number);
        }
        if(count.length()>0){
            json.add(COUNT,count);
        }
        if(text.length()>0){
            json.add(TEXT,text);
        }
        if(calendar!=null){
            json.add(CALENDER,jpti.indexOf(calendar));
        }
        JsonArray tripArray=new JsonArray();
        for(Trip trip:tripList){
            tripArray.add(jpti.indexOf(trip));
        }
        json.add(TRIP,tripArray);
        return json;
    }catch (Exception e){
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:KameLong,项目名称:AOdia,代码行数:31,代码来源:Train.java

示例11: doGet

import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
@Override
public ModelAndView doGet(IHTTPSession session) {
	ModelAndView result = new ModelAndView();
	JsonObject entity = new JsonObject();
	boolean isEnabled = config.getBoolean("satellites.enabled");
	entity.add("enabled", isEnabled);
	if (isEnabled) {
		JsonArray satellites = new JsonArray();
		List<Satellite> supported = dao.findSupported();
		for (Satellite cur : supported) {
			JsonObject satellite = new JsonObject();
			satellite.add("id", cur.getId());
			Date nextPass = scheduler.getNextObservation(cur.getId());
			if (nextPass != null) {
				satellite.add("nextPass", nextPass.getTime());
			}
			satellite.add("name", cur.getName());
			List<ObservationResult> observations = dao.findWeatherObservations(cur.getId());
			JsonArray data = new JsonArray();
			for (ObservationResult curObservation : observations) {
				JsonObject curObservationObject = new JsonObject();
				curObservationObject.add("id", curObservation.getId());
				curObservationObject.add("start", curObservation.getStart().getTime());
				curObservationObject.add("aURL", curObservation.getaURL());
				curObservationObject.add("bURL", curObservation.getbURL());
				data.add(curObservationObject);
			}
			satellite.add("data", data);
			satellites.add(satellite);
		}
		entity.add("satellites", satellites);
	}
	result.setData(entity.toString());
	return result;
}
 
开发者ID:dernasherbrezon,项目名称:r2cloud,代码行数:36,代码来源:Weather.java

示例12: doGet

import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
@Override
public ModelAndView doGet(IHTTPSession session) {
	ModelAndView result = new ModelAndView();
	if (client.isRunning()) {
		result.setStatus(Response.Status.PARTIAL_CONTENT);
	}
	JsonArray array = new JsonArray();
	int index = WebServer.getInteger(session, "index");
	List<String> messages = client.getMessages();
	for (int i = index; i < messages.size(); i++) {
		array.add(messages.get(i));
	}
	result.setData(array.toString());
	return result;
}
 
开发者ID:dernasherbrezon,项目名称:r2cloud,代码行数:16,代码来源:SSLLog.java

示例13: provisionFabric

import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
private void provisionFabric(VlanId vlanId, ConnectPoint point, ConnectPoint fromPoint) {

        long vlan = vlanId.toShort();

        JsonObject node = new JsonObject();
        node.add("vlan", vlan);
        if (vlan == 201) {
            node.add("iptv", true);
        } else {
            node.add("iptv", false);
        }
        JsonArray array = new JsonArray();
        JsonObject cp1 = new JsonObject();
        JsonObject cp2 = new JsonObject();
        cp1.add("device", point.deviceId().toString());
        cp1.add("port", point.port().toLong());
        cp2.add("device", fromPoint.deviceId().toString());
        cp2.add("port", fromPoint.port().toLong());
        array.add(cp1);
        array.add(cp2);
        node.add("ports", array);


        String baseUrl = "http://" + FABRIC_CONTROLLER_ADDRESS + ":"
                + Integer.toString(FABRIC_SERVER_PORT);
        Client client = ClientBuilder.newClient();
        WebTarget wt = client.target(baseUrl + FABRIC_BASE_URI);
        Invocation.Builder builder = wt.request(JSON_UTF_8.toString());

        builder.post(Entity.json(node.toString()));
    }
 
开发者ID:shlee89,项目名称:athena,代码行数:32,代码来源:OnosXosIntegrationManager.java

示例14: makeJSONObject

import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
public JsonObject makeJSONObject(){
    JsonObject json=new JsonObject();
    try{
        json.add(NAME,name);
        JsonArray routeArray=new JsonArray();
        for (Map.Entry<Route, Integer> bar : route.entrySet()) {
            JsonObject routeObject=new JsonObject();
            routeObject.add(ROUTE_ID,bar.getKey().index());
            routeObject.add(DIRECTION,bar.getValue());
            routeArray.add(routeObject);
        }
        json.add(ROUTE,routeArray);
        if(stationWidth>-1){
            json.add(STATION_WIDTH,stationWidth);
        }
        if(trainWidth>-1){
            json.add(TRAIN_WIDTH,trainWidth);
        }
        if(startTime!=null){
            json.add(START_TIME,startTime);
        }
        if(defaulyStationSpace>-1){
            json.add(STATION_SPACING,defaulyStationSpace);
        }
        if(comment!=null){
            json.add(COMMENT,comment);
        }
        if(diaTextColor!=null){
            json.add(DIA_TEXT_COLOR,diaTextColor.getHTMLColor());
        }
        if(diaBackColor!=null){
            json.add(DIA_BACK_COLOR,diaBackColor.getHTMLColor());
        }
        if(diaTrainColor!=null){
            json.add(DIA_TRAIN_COLOR,diaTrainColor.getHTMLColor());
        }
        if(diaAxisColor!=null){
            json.add(DIA_AXICS_COLOR,diaAxisColor.getHTMLColor());
        }
        JsonArray timetableFontArray=new JsonArray();
        for(Font font:timeTableFont){
            timetableFontArray.add(font.makeJsonObject());
        }
        json.add(TIMETABLE_FONT,timetableFontArray);
        if(timeTableVFont!=null){
            json.add(TIMETABLE_VFONT,timeTableVFont.makeJsonObject());
        }
        if(diaStationFont!=null){
            json.add(DIA_STATION_FONT,diaStationFont.makeJsonObject());
        }
        if(diaTimeFont!=null){
            json.add(DIA_TIME_FONT,diaTimeFont.makeJsonObject());
        }
        if(diaTrainFont!=null){
            json.add(DIA_TRAIN_FONT,diaTrainFont.makeJsonObject());
        }
        if(commentFont!=null){
            json.add(COMMENT_FONT,commentFont.makeJsonObject());
        }
        JsonArray trainArray=new JsonArray();
        for(Train train:trainList){
            trainArray.add(train.makeJSONObject());
        }
        json.add(TRAIN,trainArray);


    }catch(Exception e){
        e.printStackTrace();
    }
    return json;
}
 
开发者ID:KameLong,项目名称:AOdia,代码行数:72,代码来源:Service.java

示例15: sendMessage

import com.eclipsesource.json.JsonArray; //导入方法依赖的package包/类
public synchronized String sendMessage(String from, String to, double amount, double fee, String memo)
	throws WalletCallException, IOException, InterruptedException
{
	String hexMemo = Util.encodeHexString(memo);
	JsonObject toArgument = new JsonObject();
	toArgument.set("address", to);
	if (hexMemo.length() >= 2)
	{
		toArgument.set("memo", hexMemo.toString());
	}
	
	DecimalFormatSymbols decSymbols = new DecimalFormatSymbols(Locale.ROOT);

	// TODO: The JSON Builder has a problem with double values that have no fractional part
	// it serializes them as integers that ZCash does not accept. This will work with the 
	// fractional amounts always used for messaging
	toArgument.set("amount", new DecimalFormat("########0.00######", decSymbols).format(amount));

	JsonArray toMany = new JsonArray();
	toMany.add(toArgument);
	
	String toManyArrayStr =	toMany.toString();		
	String[] sendCashParameters = new String[]
    {
	    this.zcashcli.getCanonicalPath(), "z_sendmany", wrapStringParameter(from),
	    wrapStringParameter(toManyArrayStr),
	    // Default min confirmations for the input transactions is 1
	    "1",
	    // transaction fee
	    new DecimalFormat("########0.00######", decSymbols).format(fee)
	};
			
	// Create caller to send cash
    CommandExecutor caller = new CommandExecutor(sendCashParameters);
    String strResponse = caller.execute();

	if (strResponse.trim().toLowerCase(Locale.ROOT).startsWith("error:") ||
		strResponse.trim().toLowerCase(Locale.ROOT).startsWith("error code:"))
	{
	  	throw new WalletCallException("Error response from wallet: " + strResponse);
	}

	Log.info("Sending cash message with the following command: " +
               sendCashParameters[0] + " " + sendCashParameters[1] + " " +
               sendCashParameters[2] + " " + sendCashParameters[3] + " " +
               sendCashParameters[4] + " " + sendCashParameters[5] + "." +
               " Got result: [" + strResponse + "]");

	return strResponse.trim();
}
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:51,代码来源:ZCashClientCaller.java


注:本文中的com.eclipsesource.json.JsonArray.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。