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


Java JsonArray类代码示例

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


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


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