com.eclipsesource.json.JsonObject.readFrom()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(11.3k)|赞(0)|评价(0)|浏览(85)

本文整理了Java中com.eclipsesource.json.JsonObject.readFrom()方法的一些代码示例,展示了JsonObject.readFrom()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonObject.readFrom()方法的具体详情如下:
包路径:com.eclipsesource.json.JsonObject
类名称:JsonObject
方法名:readFrom

JsonObject.readFrom介绍

[英]Reads a JSON object from the given reader.

Characters are read in chunks and buffered internally, therefore wrapping an existing reader in an additional BufferedReader does not improve reading performance.
[中]从给定的读取器读取JSON对象。
字符被分块读取并在内部缓冲,因此将现有读取器包装在额外的BufferedReader中并不能提高读取性能。

代码示例

代码示例来源:origin: libgdx/packr

private static JsonObject readMinimizeProfile(PackrConfig config) throws IOException {
  JsonObject json = null;
  if (new File(config.minimizeJre).exists()) {
    json = JsonObject.readFrom(FileUtils.readFileToString(new File(config.minimizeJre)));
  } else {
    InputStream in = Packr.class.getResourceAsStream("/minimize/" + config.minimizeJre);
    if (in != null) {
      json = JsonObject.readFrom(new InputStreamReader(in));
    }
  }
  if (json == null && config.verbose) {
    System.out.println("  # No minimize profile '" + config.minimizeJre + "' found");
  }
  return json;
}

代码示例来源:origin: libgdx/packr

private void readConfigJson(File configJson) throws IOException {
  JsonObject json = JsonObject.readFrom(FileUtils.readFileToString(configJson));

代码示例来源:origin: box/box-java-sdk

/**
 * Constructs a BoxJSONObject by decoding it from a JSON string.
 * @param  json the JSON string to decode.
 */
public BoxJSONObject(String json) {
  this(JsonObject.readFrom(json));
}

代码示例来源:origin: box/box-android-sdk

/**
 *
 * @return a copy of the json object backing this object.
 */
public JsonObject toJsonObject() {
  return JsonObject.readFrom(toJson());
}

代码示例来源:origin: box/box-android-sdk

/**
 * Serializes a json blob into a BoxJsonObject.
 *
 * @param json  json blob to deserialize.
 */
public void createFromJson(String json) {
  createFromJson(JsonObject.readFrom(json));
}

代码示例来源:origin: samczsun/Skype4J

public void setSkypeToken(String skypeToken) {
  this.skypeToken = skypeToken;
  String[] data = skypeToken.split("\\.");
  JsonObject object = JsonObject.readFrom(
      new String(Base64.getDecoder().decode(data[1]), StandardCharsets.UTF_8));
  this.skypeTokenExpiryTime = object.get("exp").asLong() * 1000;
}

代码示例来源:origin: box/box-java-sdk

/**
 * Gets information about this group membership.
 * @return info about this group membership.
 */
public Info getInfo() {
  BoxAPIConnection api = this.getAPI();
  URL url = INVITE_URL_TEMPLATE.build(api.getBaseURL(), this.getID());
  BoxAPIRequest request = new BoxAPIRequest(api, url, "GET");
  BoxJSONResponse response = (BoxJSONResponse) request.send();
  JsonObject jsonObject = JsonObject.readFrom(response.getJSON());
  return new Info(jsonObject);
}

代码示例来源:origin: box/box-android-sdk

@Test
public void testTrashFileRequest() throws Exception {
  {
    final String expectedRequestUrl = "https://api.box.com/2.0/files/" + FILE_ID + "/trash";
    BoxApiFile fileApi = new BoxApiFile(SessionUtil.newMockBoxSession(mMockContext));
    BoxRequestsFile.GetTrashedFile trashedFileRequest = fileApi.getTrashedFileRequest(FILE_ID);
    mockSuccessResponseWithJson(SAMPLE_FILE_JSON);
    BoxFile boxFile = trashedFileRequest.send();
    Assert.assertEquals(expectedRequestUrl, trashedFileRequest.mRequestUrlString);
    Assert.assertEquals(JsonObject.readFrom(SAMPLE_FILE_JSON), boxFile.toJsonObject());
  }
}

代码示例来源:origin: box/box-android-sdk

@Test
public void testMockCreateEnterpriseUserRequest() throws Exception {
  final String expectedRequestUrl = "https://api.box.com/2.0/users";
  BoxApiUser userApi = new BoxApiUser(SessionUtil.newMockBoxSession(mMockContext));
  BoxRequestsUser.CreateEnterpriseUser userInfoRequest = userApi.getCreateEnterpriseUserRequest("ariellefrey@box.com", "Arielle Frey");
  mockSuccessResponseWithJson(SAMPLE_USER_JSON);
  BoxUser boxUser = userInfoRequest.send();
  Assert.assertEquals(expectedRequestUrl, userInfoRequest.mRequestUrlString);
  Assert.assertEquals(JsonObject.readFrom(SAMPLE_USER_JSON), boxUser.toJsonObject());
}

代码示例来源:origin: box/box-android-sdk

@Test
public void testFolderInfoRequest() throws Exception {
  final String expectedRequestUrl = "https://api.box.com/2.0/folders/" + FOLDER_ID;
  BoxApiFolder folderApi = new BoxApiFolder(SessionUtil.newMockBoxSession(mMockContext));
  BoxRequestsFolder.GetFolderInfo folderInfo = folderApi.getInfoRequest(FOLDER_ID);
  mockSuccessResponseWithJson(SAMPLE_FOLDER_JSON);
  BoxFolder boxFolder = folderInfo.send();
  Assert.assertEquals(expectedRequestUrl, folderInfo.mRequestUrlString);
  Assert.assertEquals(JsonObject.readFrom(SAMPLE_FOLDER_JSON), boxFolder.toJsonObject());
}

代码示例来源:origin: box/box-java-sdk

/**
 * @return information about this {@link BoxCollaborationWhitelist}.
 */
public BoxCollaborationWhitelist.Info getInfo() {
  URL url = COLLABORATION_WHITELIST_ENTRY_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
  BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, HttpMethod.GET);
  BoxJSONResponse response = (BoxJSONResponse) request.send();
  return new Info(JsonObject.readFrom(response.getJSON()));
}

代码示例来源:origin: box/box-java-sdk

/**
 * @return Gets information about this {@link BoxTermsOfService}.
 */
public BoxTermsOfService.Info getInfo() {
  URL url = TERMS_OF_SERVICE_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
  BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET");
  BoxJSONResponse response = (BoxJSONResponse) request.send();
  return new Info(JsonObject.readFrom(response.getJSON()));
}

代码示例来源:origin: box/box-java-sdk

/**
 * Gets information about this task assignment.
 * @return info about this task assignment.
 */
public Info getInfo() {
  URL url = TASK_ASSIGNMENT_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
  BoxAPIRequest request = new BoxAPIRequest(this.getAPI(), url, "GET");
  BoxJSONResponse response = (BoxJSONResponse) request.send();
  JsonObject responseJSON = JsonObject.readFrom(response.getJSON());
  return new Info(responseJSON);
}

代码示例来源:origin: box/box-android-sdk

@Test
public void testGetEnterpriseUsersRequest() throws Exception {
  final String expectedRequestUrl = "https://api.box.com/2.0/users";
  final String enterpriseUsersJson = "{ \"total_count\": 1, \"entries\": [ { \"type\": \"user\", \"id\": \"181216415\", \"name\": \"sean rose\", \"login\": \"sean+awesome@box.com\", \"created_at\": \"2012-05-03T21:39:11-07:00\", \"modified_at\": \"2012-08-23T14:57:48-07:00\", \"language\": \"en\", \"space_amount\": 5368709120, \"space_used\": 52947, \"max_upload_size\": 104857600, \"status\": \"active\", \"job_title\": \"\", \"phone\": \"5555551374\", \"address\": \"10 Cloud Way Los Altos CA\", \"avatar_url\": \"https://app.box.com/api/avatar/large/181216415\" } ] }";
  BoxApiUser userApi = new BoxApiUser(SessionUtil.newMockBoxSession(mMockContext));
  BoxRequestsUser.GetEnterpriseUsers enterpriseUsersRequest = userApi.getEnterpriseUsersRequest();
  mockSuccessResponseWithJson(enterpriseUsersJson);
  BoxIteratorUsers boxUsers = enterpriseUsersRequest.send();
  Assert.assertEquals(expectedRequestUrl, enterpriseUsersRequest.mRequestUrlString);
  Assert.assertEquals(JsonObject.readFrom(enterpriseUsersJson), boxUsers.toJsonObject());
}

代码示例来源:origin: box/box-android-sdk

@Test
public void testCopyFolderRequest() throws Exception {
  final String expectedRequestUrl = "https://api.box.com/2.0/folders/" + FOLDER_ID + "/copy" ;
  BoxApiFolder folderApi = new BoxApiFolder(SessionUtil.newMockBoxSession(mMockContext));
  BoxRequestsFolder.CopyFolder copyRequest = folderApi.getCopyRequest( FOLDER_ID, "0");
  mockSuccessResponseWithJson(SAMPLE_FOLDER_JSON);
  BoxFolder boxFolder = copyRequest.send();
  Assert.assertEquals(expectedRequestUrl, copyRequest.mRequestUrlString);
  Assert.assertEquals(JsonObject.readFrom(SAMPLE_FOLDER_JSON), boxFolder.toJsonObject());
}

代码示例来源:origin: box/box-android-sdk

@Test
public void testGetTrashedItems() throws Exception {
  final String expectedRequestUrl = "https://api.box.com/2.0/folders/trash/items" ;
  final String trashedItemsJson = "{ \"total_count\": 49542, \"entries\": [ { \"type\": \"file\", \"id\": \"2701979016\", \"sequence_id\": \"1\", \"etag\": \"1\", \"sha1\": \"9d976863fc849f6061ecf9736710bd9c2bce488c\", \"name\": \"file Tue Jul 24 145436 2012KWPX5S.csv\" }, { \"type\": \"file\", \"id\": \"2698211586\", \"sequence_id\": \"1\", \"etag\": \"1\", \"sha1\": \"09b0e2e9760caf7448c702db34ea001f356f1197\", \"name\": \"file Tue Jul 24 010055 20129Z6GS3.csv\" } ], \"offset\": 0, \"limit\": 2 }";
  BoxApiFolder folderApi = new BoxApiFolder(SessionUtil.newMockBoxSession(mMockContext));
  BoxRequestsFolder.GetTrashedItems trashedItemsRequest = folderApi.getTrashedItemsRequest( );
  mockSuccessResponseWithJson(trashedItemsJson);
  BoxIteratorItems boxItems = trashedItemsRequest.send();
  Assert.assertEquals(expectedRequestUrl, trashedItemsRequest.mRequestUrlString);
  Assert.assertEquals(JsonObject.readFrom(trashedItemsJson), boxItems.toJsonObject());
}

代码示例来源:origin: box/box-android-sdk

@Test
public void testUserInfoRequest() throws Exception {
  final String expectedRequestUrl = "https://api.box.com/2.0/users/" + USER_ID;
  BoxApiUser userApi = new BoxApiUser(SessionUtil.newMockBoxSession(mMockContext));
  BoxRequestsUser.GetUserInfo userInfoRequest = userApi.getUserInfoRequest(USER_ID);
  mockSuccessResponseWithJson(SAMPLE_USER_JSON);
  BoxUser boxUser = userInfoRequest.send();
  Assert.assertEquals(expectedRequestUrl, userInfoRequest.mRequestUrlString);
  Assert.assertEquals(JsonObject.readFrom(SAMPLE_USER_JSON), boxUser.toJsonObject());
}

代码示例来源:origin: box/box-android-sdk

@Test
public void testFileInfoRequest() throws Exception {
  final String expectedRequestUrl = "https://api.box.com/2.0/files/" + FILE_ID;
  BoxApiFile fileApi = new BoxApiFile(SessionUtil.newMockBoxSession(mMockContext));
  BoxRequestsFile.GetFileInfo fileInfoRequest = fileApi.getInfoRequest(FILE_ID);
  fileInfoRequest.setFields(BoxFile.ALL_FIELDS);
  
  mockSuccessResponseWithJson(SAMPLE_FILE_JSON);
  BoxFile boxFile = fileInfoRequest.send();
  Assert.assertEquals(expectedRequestUrl, fileInfoRequest.mRequestUrlString);
  Assert.assertEquals(JsonObject.readFrom(SAMPLE_FILE_JSON), boxFile.toJsonObject());
  
}

代码示例来源:origin: box/box-java-sdk

/**
 * Updates the information about this group with any info fields that have been modified locally.
 * @param info the updated info.
 */
public void updateInfo(BoxGroup.Info info) {
  URL url = GROUP_URL_TEMPLATE.build(this.getAPI().getBaseURL(), this.getID());
  BoxJSONRequest request = new BoxJSONRequest(this.getAPI(), url, "PUT");
  request.setBody(info.getPendingChanges());
  BoxJSONResponse response = (BoxJSONResponse) request.send();
  JsonObject jsonObject = JsonObject.readFrom(response.getJSON());
  info.update(jsonObject);
}

代码示例来源:origin: box/box-java-sdk

private BoxFileUploadSession.Info createUploadSession(BoxAPIConnection boxApi, URL url, long fileSize) {
  BoxJSONRequest request = new BoxJSONRequest(boxApi, url, HttpMethod.POST);
  //Creates the body of the request
  JsonObject body = new JsonObject();
  body.add("file_size", fileSize);
  request.setBody(body.toString());
  BoxJSONResponse response = (BoxJSONResponse) request.send();
  JsonObject jsonObject = JsonObject.readFrom(response.getJSON());
  String sessionId = jsonObject.get("id").asString();
  BoxFileUploadSession session = new BoxFileUploadSession(boxApi, sessionId);
  return session.new Info(jsonObject);
}

相关文章