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


Java JsonArray.size方法代码示例

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


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

示例1: warningsFrom

import javax.json.JsonArray; //导入方法依赖的package包/类
private static Warnings warningsFrom(JsonObject deltaResult) {
    final Warnings ws = new Warnings();

    final JsonArray jsonWarnings = deltaResult.getJsonArray("warnings");

    for (int i = 0; i < jsonWarnings.size(); ++i) {
        final JsonObject w = jsonWarnings.getJsonObject(i);

        final WarningCategory category = new WarningCategory(w.getString("category"));
        final JsonArray jsonDetails = w.getJsonArray("details");

        List<String> ds = new ArrayList<>();
        for (int j=0; j < jsonDetails.size(); j++) {
            ds.add(jsonDetails.getString(j));
        }

        final List<String> details = new ArrayList<>(ds);

        ws.add(new Warning(category, details));
    }

    return ws;
}
 
开发者ID:empear-analytics,项目名称:codescene-jenkins-plugin,代码行数:24,代码来源:DeltaAnalysisResult.java

示例2: getCookies

import javax.json.JsonArray; //导入方法依赖的package包/类
public List<Cookie> getCookies() {
  List<Cookie> res = new ArrayList<>();
  JsonObject o = inspector.sendCommand(Page.getCookies());
  JsonArray cookies = o.getJsonArray("cookies");
  if (cookies != null) {
    for (int i = 0; i < cookies.size(); i++) {
      JsonObject cookie = cookies.getJsonObject(i);
      String name = cookie.getString("name");
      String value = cookie.getString("value");
      String domain = cookie.getString("domain");
      String path = cookie.getString("path");
      Date expiry = new Date(cookie.getJsonNumber("expires").longValue());
      boolean isSecure = cookie.getBoolean("secure");
      Cookie c = new Cookie(name, value, domain, path, expiry, isSecure);
      res.add(c);
    }
    return res;
  } else {
    // TODO
  }
  return null;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:23,代码来源:RemoteIOSWebDriver.java

示例3: fetch

import javax.json.JsonArray; //导入方法依赖的package包/类
@Override
public List<Team> fetch() throws IOException {
    final JsonArray array = this.req.fetch()
        .as(RestResponse.class)
        .assertStatus(HttpURLConnection.HTTP_OK)
        .as(JsonResponse.class)
        .json()
        .readArray();
    final List<Team> teams = new ArrayList<>();
    for(int idx=0; idx<array.size(); idx++) {
        teams.add(
            new RtTeam(
                array.getJsonObject(idx),
                this.orga,
                this.versionEye
            )
        );
    }
    return teams;
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:21,代码来源:RtTeams.java

示例4: fetch

import javax.json.JsonArray; //导入方法依赖的package包/类
@Override
public List<Comment> fetch(final int page) throws IOException {
    final JsonArray array = this.req.uri()
        .queryParam("page", String.valueOf(page)).back().fetch()
        .as(RestResponse.class)
        .assertStatus(HttpURLConnection.HTTP_OK)
        .as(JsonResponse.class)
        .json()
        .readObject()
        .getJsonArray("comments");
    final List<Comment> comments = new ArrayList<>();
    for(int idx=0; idx<array.size(); idx++) {
        comments.add(
            new RtComment(array.getJsonObject(idx))
        );
    }
    return comments;
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:19,代码来源:RtComments.java

示例5: about

import javax.json.JsonArray; //导入方法依赖的package包/类
@Override
public Authenticated about() throws IOException {
    final JsonArray online = this.server.storage().build()
        .getJsonArray("authenticated");
    for(int idx = 0; idx < online.size(); idx++) {
        final JsonObject user = online.getJsonObject(idx);
        if (user.getJsonObject(this.username) != null) {
            return new MkJsonAuthenticated(
                user.getJsonObject(this.username)
            );
        }
    }
    throw new IllegalStateException(
        "User " + this.username + " is not logged in!"
    );
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:17,代码来源:MkMe.java

示例6: fetch

import javax.json.JsonArray; //导入方法依赖的package包/类
@Override
public List<Project> fetch() throws IOException {
    final List<Project> projects = new ArrayList<>();
    final JsonArray fetched = this.req.uri()
        .queryParam("orga_name", this.team.organization().name())
        .queryParam("team_name", this.team.name()).back()
        .fetch().as(RestResponse.class)
        .assertStatus(HttpURLConnection.HTTP_OK)
        .as(JsonResponse.class)
        .json()
        .readArray();
    for(int idx = 0; idx<fetched.size(); idx++) {
        projects.add(
            new RtProject(this.req, this.team, fetched.getJsonObject(idx))
        );
    }
    return projects;
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:19,代码来源:RtProjects.java

示例7: fetchOrgs

import javax.json.JsonArray; //导入方法依赖的package包/类
/**
 * Fetches the organizations that the authenticated user
 * has access to.
 * @return List of organizations.
 * @throws IOException If something goes wrong when
 *  making the HTTP call.
 */
private List<Organization> fetchOrgs() throws IOException {
    final JsonArray orgs = this.req.fetch()
        .as(RestResponse.class)
        .assertStatus(HttpURLConnection.HTTP_OK)
        .as(JsonResponse.class)
        .json()
        .readArray();
    final List<Organization> organizations = new ArrayList<>();
    for(int idx=0; idx<orgs.size(); idx++) {
        organizations.add(
            new RtOrganization(
                orgs.getJsonObject(idx), this.req, this.versionEye
            )
        );
    }
    return organizations;
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:25,代码来源:RtOrganizations.java

示例8: toList

import javax.json.JsonArray; //导入方法依赖的package包/类
public static List<Object> toList(JsonArray array) throws JsonException
{
   List<Object> list = new ArrayList<Object>();
   for (int i = 0; i < array.size(); i++)
   {
      Object value = array.get(i);
      if (value instanceof JsonArray)
      {
         value = toList((JsonArray) value);
      }
      else if (value instanceof JsonObject)
      {
         value = toMap((JsonObject) value);
      }
      list.add(value);
   }
   return list;
}
 
开发者ID:forge,项目名称:springboot-addon,代码行数:19,代码来源:ConvertHelper.java

示例9: runTests

import javax.json.JsonArray; //导入方法依赖的package包/类
public TestResults runTests(String testPackageOrClassName) throws Exception {
    final RemoteTestHttpClient testClient = new RemoteTestHttpClient(serverBaseUrl + "/system/sling/junit",serverUsername,serverPassword,true);
    final TestResults r = new TestResults();
    final Map<String, String> options = new HashMap<String, String>();
    options.put("forceReload", "true");
    final RequestExecutor executor = testClient.runTests(testPackageOrClassName, null, "json", options);
    executor.assertContentType("application/json");
    String content = executor.getContent();
    if (!content.trim().isEmpty()) {
        final JsonArray json = JsonUtil.parseArray(content);

        for(int i = 0 ; i < json.size(); i++) {
            final JsonObject obj = json.getJsonObject(i);
            if("test".equals(obj.getString("INFO_TYPE"))) {
                r.testCount++;
                if(obj.containsKey("failure")) {
                    r.failures.add(JsonUtil.toString(obj.get("failure")));
                }
            }
        }
    }

    return r;
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:25,代码来源:ServerSideTestClient.java

示例10: getPropertyArray

import javax.json.JsonArray; //导入方法依赖的package包/类
private String[] getPropertyArray(String url, String name) throws Exception {
    JsonObject jo = JsonUtil.parseObject(getContent(url + "/" + name + ".json", CONTENT_TYPE_JSON));
    JsonArray arr = jo.getJsonArray(name);
    String[] result = new String[arr.size()];
    for (int i = 0; i < arr.size(); i++) {
        result[i] = arr.getString(i);
    }
    return result;
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:10,代码来源:ReferenceTypeHintTest.java

示例11: getPropertyArray

import javax.json.JsonArray; //导入方法依赖的package包/类
public String[] getPropertyArray(String property) {
	JsonArray jsonProperties = data.getJsonArray(property);

	if (jsonProperties != null) {
		String[] properties = new String[jsonProperties.size()];
		for (int i = 0; i < properties.length; ++i) {
			properties[i] = jsonProperties.getString(i);
		}
		
		return properties;
	}
	else {
		return null;
	}
}
 
开发者ID:privacyint,项目名称:thornsec-core,代码行数:16,代码来源:ServerData.java

示例12: assertExpectedJSON

import javax.json.JsonArray; //导入方法依赖的package包/类
protected void assertExpectedJSON(JsonObject expectedJson, JsonObject actualJson) throws JsonException {
 	Iterator<String> keys = expectedJson.keySet().iterator();
 	while (keys.hasNext()) {
 		String key = keys.next();

 		Object object = expectedJson.get(key);
 		Object object2 = actualJson.get(key);
if (object instanceof JsonObject) {
	assertTrue(object2 instanceof JsonObject);
 			assertExpectedJSON((JsonObject)object, (JsonObject)object2);
} else if (object instanceof JsonArray) {
	//compare the array
	assertTrue(object2 instanceof JsonArray);
	JsonArray actualArray = (JsonArray)object2;
	Set<Object> actualValuesSet = new HashSet<Object>();
	for (int i=0; i < actualArray.size(); i++) {
		actualValuesSet.add(actualArray.get(i));
	}

	JsonArray expectedArray = (JsonArray)object;
	for (int i=0; i < expectedArray.size(); i++) {
		assertTrue(actualValuesSet.contains(expectedArray.get(i)));
	}
 		} else {
 			assertEquals("Value of key: " + key, object, object2);
 		}
 	}
 }
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:29,代码来源:PostServletImportTest.java

示例13: convert

import javax.json.JsonArray; //导入方法依赖的package包/类
private void convert(JsonArray json) {
    builder.append("Json.createArrayBuilder()\n");
    for (int i = 0; i < json.size(); i++) {
        builder.append(spaces() + indent() + ".add(" + new JsonConversion(indent + INDENT_INCREMENT).execute(json.get(i)) + ")");

        if(i != json.size() -1) {
            builder.append("\n");
        }
    }
}
 
开发者ID:msemik,项目名称:json_converter,代码行数:11,代码来源:JsonConversion.java

示例14: getAttachments

import javax.json.JsonArray; //导入方法依赖的package包/类
public static  List<AttachmentDao> getAttachments(JsonArray attachmentsList) {
    List<AttachmentDao> list = new ArrayList<>();
    if(!attachmentsList.isEmpty()){
         for(int i =0; i < attachmentsList.size(); i++){
             list.add(getAttachment(attachmentsList.getJsonObject(i)));
        }
    }       
    return list;
}
 
开发者ID:avraampiperidis,项目名称:DiavgeiaUtils,代码行数:10,代码来源:DecisionDaoProviderBuilder.java

示例15: Group

import javax.json.JsonArray; //导入方法依赖的package包/类
public Group(String json) throws Exception {
  JsonObject jObject = stringToJsonObj(json);
  this.id = jObject.getString(JSON_KEY_GROUP_ID);
  this.name = jObject.getString(JSON_KEY_GROUP_NAME);

  JsonArray jsonMembers = jObject.getJsonArray(JSON_KEY_MEMBERS_LIST);
  if (jsonMembers != null) {
    members = new String[jsonMembers.size()];
    for (int i = 0; i < jsonMembers.size(); i++) {
      members[i] = jsonMembers.getString(i);
    }
  } else {
    members = new String[0];
  }
}
 
开发者ID:OpenLiberty,项目名称:sample-acmegifts,代码行数:16,代码来源:Group.java


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