Java 类javax.json.JsonArray 实例源码

项目:codescene-jenkins-plugin    文件:DeltaAnalysisResult.java   
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;
}
项目:versioneye-api    文件:RtTeams.java   
@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;
}
项目:versioneye-api    文件:RtRepositories.java   
@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;
}
项目:versioneye-api    文件:RtComments.java   
@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;
}
项目:versioneye-api    文件:MkNewUser.java   
@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"));
}
项目:versioneye-api    文件:RtProjects.java   
@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;
}
项目:jb-hub-client    文件:RtPaginationIterator.java   
/**
 * 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);
}
项目:versioneye-api    文件:RtOrganizations.java   
/**
 * 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;
}
项目:inbox    文件:MessagesResource.java   
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;
}
项目:json_converter    文件:JsonConversion.java   
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());
}
项目:cedato-api-client    文件:SupIterator.java   
/**
 * 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();
}
项目:ios-device-control    文件:SimulatorDeviceHost.java   
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());
}
项目:microprofile-rest-client    文件:InvokeWithJsonPProviderTest.java   
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);

}
项目:TBAShell    文件:TbaApiV3.java   
/**
 * 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;
}
项目:oauth-filter-for-java    文件:JwksResponse.java   
JwksResponse(JsonObject jsonObject)
{
    JsonValue keys = jsonObject.get("keys");

    if (keys.getValueType() != JsonValue.ValueType.ARRAY)
    {
        _keys = Collections.emptyList();
    }
    else
    {
        _keys = Stream.of((JsonArray)keys)
                .filter(it -> it.getValueType() == JsonValue.ValueType.OBJECT)
                .map(it -> (JsonObject) it)
                .map(JsonWebKey::new)
                .collect(Collectors.toList());
    }
}
项目:devtools-driver    文件:JavaxJson.java   
/**
 * Converts a {@link JsonValue} to its corresponding Java object. Values of type {@link
 * JsonObject} or {@link JsonArray} are converted as specified by {@link #toJavaMap} and {@link
 * #toJavaList}, respectively.
 */
@Nullable
public static Object toJavaObject(JsonValue value) {
  switch (value.getValueType()) {
    case ARRAY:
      return toJavaList((JsonArray) value);
    case FALSE:
      return Boolean.FALSE;
    case NULL:
      return null;
    case NUMBER:
      JsonNumber number = (JsonNumber) value;
      return number.isIntegral() ? number.intValue() : number.doubleValue();
    case OBJECT:
      return toJavaMap((JsonObject) value);
    case STRING:
      return ((JsonString) value).getString();
    case TRUE:
      return Boolean.TRUE;
    default:
      throw new VerifyException("Json value with unknown type: " + value);
  }
}
项目:devtools-driver    文件:CommandGenerationTest.java   
@Test
public void testGeneratedMessageWithTypes() {
  JsonArray canonicalArguments =
      Json.createArrayBuilder()
          .add(Runtime.callArgument().withValue("val").withObjectId("567").properties())
          .add(Runtime.callArgument().withValue(3).withObjectId("789").properties())
          .build();
  ImmutableList<Runtime.CallArgument> argumentsList =
      ImmutableList.of(
          Runtime.callArgument().withValue("val").withObjectId("567"),
          Runtime.callArgument().withValue(3).withObjectId("789"));
  DevtoolsCommand first =
      Runtime.callFunctionOn("123", "function funky() { return 2; }")
          .withArguments(argumentsList)
          .withDoNotPauseOnExceptionAndMuteConsole(true)
          .withGeneratePreview(false);

  JsonObject firstParams = first.params();
  assertThat(firstParams.getJsonArray("arguments")).isEqualTo(canonicalArguments);
}
项目:devtools-driver    文件:RemoteIOSWebDriver.java   
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;
}
项目:devtools-driver    文件:SetValueHandler.java   
@Override
public Response handle() throws Exception {
  String ref = getRequest().getVariableValue(":reference");
  RemoteWebElement element = getWebDriver().createElement(ref);
  JsonArray array = getRequest().getPayload().getJsonArray("value");

  String value = "";
  for (JsonValue jsonValue : array) {
    value += JavaxJson.toJavaObject(jsonValue);
  }
  element.setValueAtoms(value);

  Response res = new Response();
  res.setSessionId(getSession().getSessionId());
  res.setStatus(0);
  res.setValue(new JSONObject());
  return res;
}
项目:springboot-addon    文件:ConvertHelper.java   
public static Map<String, Object> toMap(JsonObject object) throws JsonException
{
   Map<String, Object> map = new HashMap<String, Object>();

   Iterator<String> keysItr = object.keySet().iterator();
   while(keysItr.hasNext()) {
      String key = keysItr.next();
      Object value = object.get(key);

      if(value instanceof JsonArray) {
         value = toList((JsonArray) value);
      }
      else if(value instanceof JsonObject) {
         value = toMap((JsonObject) value);
      }
      map.put(key, value);
   }
   return map;
}
项目:springboot-addon    文件:ConvertHelper.java   
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;
}
项目:javaee8-applications    文件:CustomerController.java   
public void findCustomerByAddress() {
    searchResult = null;
    String text = "/" + this.addressSearchText;
    JsonObject json = Json.createObjectBuilder().build();
    JsonValue object = json.getJsonObject(fetchJson());
    if (addressSearchText != null) {
        JsonPointer pointer = Json.createPointer(text);
        JsonValue result = pointer.getValue(object.asJsonArray());

        // Replace a value
        JsonArray array = (JsonArray) pointer.replace(object.asJsonArray(), Json.createValue("1000 JsonP Drive"));
        searchResult = array.toString();
        //searchResult = result.toString();
    }

}
项目:E-Clinic    文件:ContactRestEndPoint.java   
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = contactService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getContactId())
                .add("name", h.getValue())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
项目:E-Clinic    文件:GuardianRestEndPoint.java   
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = guardianService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getGuardianId())
                .add("name", h.getParentID().getFirstName())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
项目:E-Clinic    文件:ScheduleRestEndPoint.java   
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = scheduleService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getSchedule())
                .add("name", "expand")
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
项目:E-Clinic    文件:GenderRestEndPoint.java   
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = genderService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getGenderId())
                .add("value", h.getGenderName())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
项目:E-Clinic    文件:ReligionRestEndPoint.java   
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = religionService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getReligionId())
                .add("name", h.getName())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
项目:E-Clinic    文件:AddressRestEndPoint.java   
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = addressService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getAddressId())
                .add("name", h.getStreetName())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
项目:E-Clinic    文件:NurseRestEndPoint.java   
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        List<Nurse> get = nurseService.get();
        List<Nurse> collect = get.stream().collect(Collectors.toList());
        build = collect.stream().map(h -> Json.createObjectBuilder()
                .add("firstname", h.getPersonId().getFirstName())
                .add("lastname", h.getPersonId().getLastName())
                .add("id", h.getNurseId())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
项目:E-Clinic    文件:PersonRestEndPoint.java   
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = personService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getPersonId())
                .add("name", h.getFirstName())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
项目:E-Clinic    文件:MartialStatusRestEndPoint.java   
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = martialStatusService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getMartialStatusId())
                .add("name", h.getMartialStatusName())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
项目:E-Clinic    文件:PersonArchiveRestEndPoint.java   
@GET
@Path("find")
@Produces(MediaType.APPLICATION_JSON)
public Response find() {
    JsonArray build = null;
    try {
        build = personArchiveService.get().stream().map(h -> Json.createObjectBuilder()
                .add("id", h.getPersonArchiveId())
                .add("name", h.getFirstName())
                .build())
                .collect(Json::createArrayBuilder, JsonArrayBuilder::add, JsonArrayBuilder::add)
                .build();
    } catch (Exception ex) {
        return Response.ok().header("Exception", ex.getMessage()).build();
    }
    return Response.ok().entity(build == null ? "No data found" : build).build();
}
项目:sample-acmegifts    文件:Group.java   
/**
 * Create a group based on a JSON Object
 *
 * @param group The JSON Object with group information
 */
public Group(JsonObject group) {
  if (group.containsKey(JSON_KEY_GROUP_ID)) {
    id = group.getString(JSON_KEY_GROUP_ID);
  }
  name = group.getString(JSON_KEY_GROUP_NAME);

  JsonArray jsonMembers = group.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];
  }
}
项目:perceptor    文件:MonitoringIT.java   
@Test
public void exceptionalStats() {
    try {
        invokeMethod("exceptional");
    } catch (Exception ex) {
    }
    //[{"hostName":"unknown","methodName":"public java.lang.String com.bmw.eve.fastandslow.boundary.Invoker.exceptional()",
    //"recentDuration":0,"minDuration":0,"maxDuration":0,"averageDuration":0,"numberOfExceptions":1,"numberOfInvocations":1,
    //"exception":"java.lang.IllegalStateException: Don't call me!","lastInvocationTimestamp":1469431094017,"totalDuration":0}]
    JsonArray invocationStatistics = this.methodsMonitoringTarget.
            request(MediaType.APPLICATION_JSON).
            get(JsonArray.class);
    assertThat(invocationStatistics.size(), is(1));
    System.out.println("invocationStatistics = " + invocationStatistics);
    long count = invocationStatistics.stream().map(a -> (JsonObject) a).
            map(i -> i.getString("methodName")).
            filter(m -> !m.contains("exceptional")).
            count();
    assertThat(count, is(0l));
    JsonObject invocation = invocationStatistics.getJsonObject(0);
    int numberOfInvocations = invocation.getInt("numberOfInvocations");
    assertThat(numberOfInvocations, is(1));
    int numberOfExceptions = invocation.getInt("numberOfExceptions");
    assertThat(numberOfExceptions, is(1));
}
项目:HueSense    文件:HueComm.java   
private boolean getKey() throws IOException {
    String resp = makeQuery(POST, PROTOCOL + bridge.getIp() + API, IDENTBODY);
    if (resp != null) {
        JsonReader reader = Json.createReader(new StringReader(resp));
        JsonArray arr = reader.readArray();
        JsonObject obj = arr.getJsonObject(0);
        if (obj.containsKey("success")) {
            JsonObject success = obj.getJsonObject("success");
            bridge.setKey(success.getString("username"));
            LOG.info("Got key from bridge");
            return true;
        }

    }
    return false;
}
项目:versioneye-api    文件:MkVersionEye.java   
/**
 * Add authenticated user to the MkServer.
 * @param authenticated The user to authenticate.
 */
private void authenticate(final Authenticated authenticated) {
    final JsonArray online = this.server.storage().build()
        .getJsonArray("authenticated");
    final JsonArrayBuilder users = Json.createArrayBuilder();
    for(final JsonValue user: online) {
        users.add(user);
    }
    users.add(Json.createObjectBuilder().add(
        this.username, authenticated.json())
    );
    this.server.storage().add("authenticated", users.build());
}
项目:versioneye-api    文件:RtProject.java   
@Override
public List<String> childIds() {
    final List<String> children = new ArrayList<>();
    final JsonArray ids = this.project.getJsonArray("child_ids");
    for(int idx = 0; idx< ids.size(); idx++) {
        children.add(ids.getString(idx));
    }
    return children;
}
项目:versioneye-api    文件:JsonVulnerability.java   
@Override
public List<String> affectedVersions() {
    final List<String> affected;
    final JsonArray versions = this.vulnerability
        .getJsonArray("affected_versions");
    if(versions == null) {
        affected = new ArrayList<>();
    } else {
        affected = new ArrayList<>();
        for(final JsonValue version : versions) {
            affected.add(((JsonString) version).getString());
        }
    }
    return affected;
}
项目:inbox    文件:MessagesResource.java   
private JsonObject getMessages() throws Exception {
URL noteUrl = new URL("https://rerum-inbox.firebaseio.com/messages.json"+buildQuery());
HttpURLConnection conn = (HttpURLConnection) noteUrl.openConnection();
InputStreamReader isr = new InputStreamReader(conn.getInputStream(),"UTF-8");
JsonReader reader = Json.createReader(isr);
JsonArray messages = readMessages(reader);
return formatList(messages);
}
项目:inbox    文件:MessagesResource.java   
private JsonObject formatList(JsonArray arr){
    JsonObject response;
    JsonObjectBuilder b = Json.createObjectBuilder();
    b.add("@context", CONTEXT);
    b.add("@type", TYPE);
    b.add("@id", ID_ROOT+"?target="+TARGET);
    b.add("contains",arr);
    response = b.build();
    return response;
}