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


Java JsonArray类代码示例

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


JsonArray类属于javax.json包,在下文中一共展示了JsonArray类的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<Repository> fetch(final int page) throws IOException {
    final JsonArray results = this.req.uri()
        .queryParam("page", String.valueOf(page)).back().fetch()
        .as(RestResponse.class)
        .assertStatus(HttpURLConnection.HTTP_OK)
        .as(JsonResponse.class)
        .json()
        .readObject()
        .getJsonArray("repos");
    final List<Repository> repositories = new ArrayList<>();
    for(int idx=0; idx<results.size(); idx++) {
        repositories.add(
            new RtRepository(results.getJsonObject(idx), this.req)
        );
    }
    return repositories;
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:19,代码来源:RtRepositories.java

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

示例6: signUp

import javax.json.JsonArray; //导入依赖的package包/类
@Override
public User signUp() {
    final JsonArray registered = this.server.storage().build()
        .getJsonArray("users");
    final JsonArrayBuilder users = Json.createArrayBuilder();
    for(final JsonValue user: registered) {
        users.add(user);
    }
    users.add(
        Json.createObjectBuilder()
            .add(
                this.json.getString("username"),
                this.json
            )
    );
    this.server.storage().add("users", users.build());
    return new MkUser(this.server, this.json.getString("username"));
}
 
开发者ID:decorators-squad,项目名称:versioneye-api,代码行数:19,代码来源:MkNewUser.java

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

示例8: fetch

import javax.json.JsonArray; //导入依赖的package包/类
/**
 * Get json Array projects.
 * @return Array projects
 * @throws Exception If fails
 */
private JsonArray fetch() throws Exception {
    if (this.response.get() != null) {
        final Optional<Request> next = this.response
            .get()
            .as(PaginationResponse.class)
            .next();
        if (next.has()) {
            this.response.set(
                next.value().fetch()
            );
        } else {
            throw new NoSuchElementException();
        }
    } else {
        this.response.set(this.req.fetch());
    }
    return this.response.get()
        .as(RestResponse.class)
        .assertStatus(HttpURLConnection.HTTP_OK)
        .as(JsonResponse.class)
        .json()
        .readObject()
        .getJsonArray(name);
}
 
开发者ID:smallcreep,项目名称:jb-hub-client,代码行数:30,代码来源:RtPaginationIterator.java

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

示例10: readMessages

import javax.json.JsonArray; //导入依赖的package包/类
private JsonArray readMessages(JsonReader reader) throws Exception {
           JsonArrayBuilder b = Json.createArrayBuilder();
           JsonObject obj;
                   try{
           obj = reader.readObject();
           } finally {
               reader.close();
           }
           obj.entrySet().forEach(e -> 
           {
               Message msg=new Message();
               JsonObject m;
               m = msg.generate(e.getValue().toString(), "@id", "http://inbox.rerum.io/id/" + e.getKey() + "");
               if(MOTIVATION.length()==0 || MOTIVATION.contains(m.getJsonString("motivation").toString())){
                   b.add(m);
               }
               });
           JsonArray messages = b.build();
           return messages;
}
 
开发者ID:CenterForDigitalHumanities,项目名称:inbox,代码行数:21,代码来源:MessagesResource.java

示例11: convert

import javax.json.JsonArray; //导入依赖的package包/类
private void convert(JsonValue json) {
    if (json == null) {
        builder.append("null");
        return;
    }
    if (json instanceof JsonObject) {
        convert(((JsonObject) json));
        return;
    }
    if (json instanceof JsonArray) {
        convert(((JsonArray) json));
        return;
    }

    builder.append(json.toString());
}
 
开发者ID:msemik,项目名称:json_converter,代码行数:17,代码来源:JsonConversion.java

示例12: supply

import javax.json.JsonArray; //导入依赖的package包/类
/**
 * Get supply by index.
 * @param index Supply index
 * @return Supply
 */
private Supply supply(final int index) {
    final JsonArray supplies = this.json()
                                   .getJsonObject("data")
                                   .getJsonArray("supplies");
    final AtomicReference<Supply> result = new AtomicReference<>();
    if (supplies.size() > index) {
        result.set(
            new JsSupply(
                this.origin,
                supplies.getJsonObject(index)
            )
        );
    }
    return result.get();
}
 
开发者ID:smallcreep,项目名称:cedato-api-client,代码行数:21,代码来源:SupIterator.java

示例13: collectDevices

import javax.json.JsonArray; //导入依赖的package包/类
private ImmutableSet<IosDevice> collectDevices(Predicate<JsonObject> test) throws IOException {
  String devices = await(SimctlCommands.list()).stdoutStringUtf8();
  JsonObject jsonOutput = JsonParser.parseObject(devices).getJsonObject("devices");
  return jsonOutput
      .entrySet()
      .stream()
      .filter(e -> e.getKey().startsWith("iOS"))
      .flatMap(
          e -> {
            IosVersion version = getVersion(e.getKey().substring(4));
            return ((JsonArray) e.getValue())
                .stream()
                .map(v -> (JsonObject) v)
                .filter(test)
                .map(data -> toDevice(version, data));
          })
      .collect(toImmutableSet());
}
 
开发者ID:google,项目名称:ios-device-control,代码行数:19,代码来源:SimulatorDeviceHost.java

示例14: testGet

import javax.json.JsonArray; //导入依赖的package包/类
private void testGet(JsonPClient client, String clientType) {
    reset();
    stubFor(get(urlEqualTo("/"))
        .willReturn(aResponse()
            .withBody("[{\"key\": \"value\"}, {\"key\": \"anotherValue\"}]")));
    JsonArray jsonArray = client.get();
    assertEquals(jsonArray.size(), 2, "Expected 2 values in the array for client "+clientType);
    List<JsonObject> jsonObjects = jsonArray.getValuesAs(JsonObject.class);
    JsonObject one = jsonObjects.get(0);
    assertEquals(one.keySet().size(), 1, "There should only be one key in object 1 for client "+clientType);
    assertEquals(one.getString("key"), "value", "The value of 'key' on object 1 should be 'value' in client "+clientType);

    JsonObject two = jsonObjects.get(1);
    assertEquals(two.keySet().size(), 1, "There should only be one key in object 2 for client "+clientType);
    assertEquals(two.getString("key"), "anotherValue", "The value of 'key' on object 2 should be 'anotherValue' in client "+clientType);

}
 
开发者ID:eclipse,项目名称:microprofile-rest-client,代码行数:18,代码来源:InvokeWithJsonPProviderTest.java

示例15: addTeams

import javax.json.JsonArray; //导入依赖的package包/类
/**
 * This method adds teams of the specified page to the teams array.
 *
 * @param arrBuilder specifies the array builder to add the teams into.
 * @param year specifies the optional year, null for all years.
 * @param pageNum specifies the page number.
 * @param verbosity specifies optional verbosity, null for full verbosity.
 * @param statusOut specifies standard output stream for command status, can be null for quiet mode.
 * @return true if successful, false if failed.
 */
private boolean addTeams(
    JsonArrayBuilder arrBuilder, String year, int pageNum, String verbosity, PrintStream statusOut)
{
    String request = "teams/";
    if (year != null) request += year + "/";
    request += pageNum;
    if (verbosity != null) request += "/" + verbosity;

    JsonStructure data = get(request, statusOut, header);
    boolean success;
    if (data != null && data.getValueType() == JsonValue.ValueType.ARRAY && !((JsonArray)data).isEmpty())
    {
        for (JsonValue team: (JsonArray)data)
        {
            arrBuilder.add(team);
        }
        success = true;
    }
    else
    {
        success = false;
    }

    return success;
}
 
开发者ID:trc492,项目名称:TBAShell,代码行数:36,代码来源:TbaApiV3.java


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