• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java JsonArray类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testFlowsSingleDevice

import com.eclipsesource.json.JsonArray; //导入依赖的package包/类
/**
 * Tests the result of a rest api GET for a device.
 */
@Test
public void testFlowsSingleDevice() {
    setupMockFlows();
    final Set<FlowEntry> flows = new HashSet<>();
    flows.add(flow5);
    flows.add(flow6);
    expect(mockFlowService.getFlowEntries(anyObject()))
            .andReturn(flows).anyTimes();
    replay(mockFlowService);
    replay(mockDeviceService);
    final WebTarget wt = target();
    final String response = wt.path("flows/" + deviceId3).request().get(String.class);
    final JsonObject result = Json.parse(response).asObject();
    assertThat(result, notNullValue());

    assertThat(result.names(), hasSize(1));
    assertThat(result.names().get(0), is("flows"));
    final JsonArray jsonFlows = result.get("flows").asArray();
    assertThat(jsonFlows, notNullValue());
    assertThat(jsonFlows, hasFlow(flow5));
    assertThat(jsonFlows, hasFlow(flow6));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:FlowsResourceTest.java


示例2: getArrayString

import com.eclipsesource.json.JsonArray; //导入依赖的package包/类
public static ArrayList<String> getArrayString(JsonArray jsonArray)
{
	ArrayList<String> data = new ArrayList<String>();
	
	for (JsonValue jsonValue : jsonArray)
	{
		
		data.add(
				isNumeric(jsonValue.toString()) ? jsonValue.toString() :
					jsonValue.asString()
				);
	}
	
	return data;
	
}
 
开发者ID:rodrigoEclipsa,项目名称:excelToApp,代码行数:17,代码来源:GeneralUtil.java


示例3: Route

import com.eclipsesource.json.JsonArray; //导入依赖的package包/类
public Route(JPTI jpti,JsonObject json){
    this(jpti);
    try{
        agencyID=json.getInt(AGENCY_ID,-1);
        number=json.getInt(NO,-1);
        name=json.getString(NAME,"");
        nickName=json.getString(NICKNAME,"");
        description=json.getString(DESCRIPTION,"");
        type=json.getInt(TYPE,2);
        url=json.getString(URL,"");
            color=new Color(json.getString(COLOR,"#000000"));
            textColor=new Color(json.getString(TEXT_COLOR,""));
            JsonArray stationArray=json.get(STATION).asArray();
            for(int i=0;i<stationArray.size();i++){
                stationList.add(newRouteStation(stationArray.get(i).asObject()));
            }

    }catch (Exception e){

    }
}
 
开发者ID:KameLong,项目名称:AOdia,代码行数:22,代码来源:Route.java


示例4: Operation

import com.eclipsesource.json.JsonArray; //导入依赖的package包/类
public Operation(JPTI jpti, JsonObject json) {
    this.jpti = jpti;
    operationName = json.getString(OPERATION_NAME, "");
    operationNumber = json.getInt(OPERATION_NO, -1);
    calenderID = json.getInt(CALENDER_ID, -1);

    JsonArray array = json.get(TRIP_LIST).asArray();
    for (int i = 0; i < array.size(); i++) {
        JsonObject obj = array.get(i).asObject();
        try {
            trip.add(jpti.getTrip(obj.getInt(TRIP_ID, -1)));
        }catch (Exception e){
            SdLog.log(e);
        }
    }
}
 
开发者ID:KameLong,项目名称:AOdia,代码行数:17,代码来源:Operation.java


示例5: 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


示例6: Station

import com.eclipsesource.json.JsonArray; //导入依赖的package包/类
public Station(JPTI jpti, JsonObject json){
    this(jpti);
    try{
            name =json.getString(NAME,"駅名不明");
        subName=json.getString(SUBNAME,"");
        type=json.getInt(TYPE,0);
            description = json.getString(DESCRIPTION, "");
        lat=json.getString(LAT,"");
        lon=json.getString(LON,"");
        url=json.getString(URL,"");
        wheelcharBoarding=json.getString(WHEELCHAIR,"");
        JsonArray stopArray=json.get(STOP).asArray();
        for(int i=0;i<stopArray.size();i++){
            stops.add(jpti.getStop(stopArray.get(i).asInt()));
            jpti.getStop(stopArray.get(i).asInt()).setStation(this);
        }
    }catch (Exception e){
        e.printStackTrace();
    }
}
 
开发者ID:KameLong,项目名称:AOdia,代码行数:21,代码来源:Station.java


示例7: Trip

import com.eclipsesource.json.JsonArray; //导入依赖的package包/类
public Trip(JPTI jpti, JsonObject json){
    this.jpti=jpti;
    try{
        route=jpti.getRoute(json.getInt(ROUTE,0));
            this.traihType=jpti.getTrainType(json.getInt(CLASS,0));
            blockID=json.getInt(BLOCK,0);
            calender=jpti.calendarList.get(json.getInt(CALENDER,0));
        number=json.getString(NUMBER,"");
        name=json.getString(NAME,"");
        direction=json.getInt(DIRECTION,0);
        extraCalendarID=json.getInt(EXTRA_CALENDER,-1);
        JsonArray timeArray=json.get(TIME).asArray();
        for(int i=0;i<timeArray.size();i++){
            Time time=newTime(timeArray.get(i).asObject());
            timeList.put(time.getStation(),time);
        }




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


示例8: addBlockMining

import com.eclipsesource.json.JsonArray; //导入依赖的package包/类
private static void addBlockMining(JsonArray prop, JBlock block) {
	if (prop != null) {
		JsonObject object = prop.asObject();
		for (JsonObject.Member member : object) {
			switch (member.getName()) {
			case "speed":
				block.setMiningTime(member.getValue().asFloat());
				break;
			case "tool":
				block.setMiningTool(ItemJson.toolType(member.getValue().asString()));
				break;
			case "toolLevel":
				block.setMiningToolLevel(member.getValue().asInt());
				break;
			case "other":
				block.setMiningOther(member.getValue().asBoolean());
				break;
			default:
				throw new JsonException("Unexpected item tool member \"" + member.getName() + "\"");
			}
		}
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:24,代码来源:BlockJson.java


示例9: matchesSafely

import com.eclipsesource.json.JsonArray; //导入依赖的package包/类
@Override
public boolean matchesSafely(JsonArray json) {
    boolean flowFound = false;

    for (int jsonFlowIndex = 0; jsonFlowIndex < json.size();
         jsonFlowIndex++) {

        final JsonObject jsonFlow = json.get(jsonFlowIndex).asObject();

        final String flowId = Long.toString(flow.id().value());
        final String jsonFlowId = jsonFlow.get("id").asString();
        if (jsonFlowId.equals(flowId)) {
            flowFound = true;

            //  We found the correct flow, check attribute values
            assertThat(jsonFlow, matchesFlow(flow, APP_ID.name()));
        }
    }
    if (!flowFound) {
        reason = "Flow with id " + flow.id().toString() + " not found";
        return false;
    } else {
        return true;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:FlowsResourceTest.java


示例10: matchesSafely

import com.eclipsesource.json.JsonArray; //导入依赖的package包/类
@Override
public boolean matchesSafely(JsonArray json) {
    boolean itemFound = false;
    final int expectedAttributes = jsonFieldNames.size();
    for (int jsonArrayIndex = 0; jsonArrayIndex < json.size();
         jsonArrayIndex++) {

        final JsonObject jsonHost = json.get(jsonArrayIndex).asObject();

        if (jsonHost.names().size() < expectedAttributes) {
            reason = "Found a virtual network with the wrong number of attributes";
            return false;
        }

        if (checkKey != null && checkKey.test(vnetEntity, jsonHost)) {
            itemFound = true;
            assertThat(jsonHost, matchesVnetEntity(vnetEntity, jsonFieldNames, getValue));
        }
    }
    if (!itemFound) {
        reason = getKey.apply(vnetEntity) + " was not found";
        return false;
    }
    return true;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:VirtualNetworkWebResourceTest.java


示例11: isSendingOperationComplete

import com.eclipsesource.json.JsonArray; //导入依赖的package包/类
public synchronized boolean isSendingOperationComplete(String opID)
    throws WalletCallException, IOException, InterruptedException
{
	JsonArray response = this.executeCommandAndGetJsonArray(
		"z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]"));
	JsonObject jsonStatus = response.get(0).asObject();

	String status = jsonStatus.getString("status", "ERROR");

	Log.info("Operation " + opID + " status is " + response + ".");

	if (status.equalsIgnoreCase("success") ||
		status.equalsIgnoreCase("error") ||
		status.equalsIgnoreCase("failed"))
	{
		return true;
	} else if (status.equalsIgnoreCase("executing") || status.equalsIgnoreCase("queued"))
	{
		return false;
	} else
	{
		throw new WalletCallException("Unexpected status response from wallet: " + response.toString());
	}
}
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:25,代码来源:ZCashClientCaller.java


示例12: isCompletedOperationSuccessful

import com.eclipsesource.json.JsonArray; //导入依赖的package包/类
public synchronized boolean isCompletedOperationSuccessful(String opID)
    throws WalletCallException, IOException, InterruptedException
{
	JsonArray response = this.executeCommandAndGetJsonArray(
		"z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]"));
	JsonObject jsonStatus = response.get(0).asObject();

	String status = jsonStatus.getString("status", "ERROR");

	Log.info("Operation " + opID + " status is " + response + ".");

	if (status.equalsIgnoreCase("success"))
	{
		return true;
	} else if (status.equalsIgnoreCase("error") || status.equalsIgnoreCase("failed"))
	{
		return false;
	} else
	{
		throw new WalletCallException("Unexpected final operation status response from wallet: " + response.toString());
	}
}
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:23,代码来源:ZCashClientCaller.java


示例13: getSuccessfulOperationTXID

import com.eclipsesource.json.JsonArray; //导入依赖的package包/类
public synchronized String getSuccessfulOperationTXID(String opID)
       throws WalletCallException, IOException, InterruptedException
{
	String TXID = null;
	JsonArray response = this.executeCommandAndGetJsonArray(
		"z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]"));
	JsonObject jsonStatus = response.get(0).asObject();
	JsonValue  opResultValue = jsonStatus.get("result"); 
	
	if (opResultValue != null)
	{
		JsonObject opResult = opResultValue.asObject();
		if (opResult.get("txid") != null)
		{
			TXID = opResult.get("txid").asString();
		}
	}
	
	return TXID;
}
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:21,代码来源:ZCashClientCaller.java


示例14: decomposeJSONValue

import com.eclipsesource.json.JsonArray; //导入依赖的package包/类
private void decomposeJSONValue(String name, JsonValue val, Map<String, String> map)
{
	if (val.isObject())
	{
		JsonObject obj = val.asObject();
		for (String memberName : obj.names())
		{
			this.decomposeJSONValue(name + "." + memberName, obj.get(memberName), map);
		}
	} else if (val.isArray())
	{
		JsonArray arr = val.asArray();
		for (int i = 0; i < arr.size(); i++)
		{
			this.decomposeJSONValue(name + "[" + i + "]", arr.get(i), map);
		}
	} else
	{
		map.put(name, val.toString());
	}
}
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:22,代码来源:ZCashClientCaller.java


示例15: 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


示例16: 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


示例17: 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


示例18: 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


示例19: isSendingOperationComplete

import com.eclipsesource.json.JsonArray; //导入依赖的package包/类
public synchronized boolean isSendingOperationComplete(String opID)
    throws WalletCallException, IOException, InterruptedException
{
	JsonArray response = this.executeCommandAndGetJsonArray(
		"z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]"));
	JsonObject jsonStatus = response.get(0).asObject();

	String status = jsonStatus.getString("status", "ERROR");

	System.out.println("Operation " + opID + " status is " + response + ".");

	if (status.equalsIgnoreCase("success") ||
		status.equalsIgnoreCase("error") ||
		status.equalsIgnoreCase("failed"))
	{
		return true;
	} else if (status.equalsIgnoreCase("executing") || status.equalsIgnoreCase("queued"))
	{
		return false;
	} else
	{
		throw new WalletCallException("Unexpected status response from wallet: " + response.toString());
	}
}
 
开发者ID:ca333,项目名称:komodoGUI,代码行数:25,代码来源:ZCashClientCaller.java


示例20: matchesSafely

import com.eclipsesource.json.JsonArray; //导入依赖的package包/类
@Override
protected boolean matchesSafely(JsonArray json) {
    boolean found = false;
    for (int index = 0; index < json.size(); index++) {
        final JsonObject jsonMcastRoute = json.get(index).asObject();

        final String source = route.source().toString();
        final String group = route.group().toString();
        final String type = route.type().toString();
        final String jsonSource = jsonMcastRoute.get("source").asString();
        final String jsonGroup = jsonMcastRoute.get("group").asString();
        final String jsonType = jsonMcastRoute.get("type").asString();

        if (jsonSource.equals(source) && jsonGroup.equals(group) &&
                jsonType.equals(type)) {
            found = true;
            assertThat(jsonMcastRoute, matchesMcastRoute(route));
        }
    }

    return found;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:MulticastRouteResourceTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ArtifactResolver类代码示例发布时间:2022-05-20
下一篇:
Java IdleStatus类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap