Java 类org.json.simple.DeserializationException 实例源码

项目:shipkit    文件:GitHubListFetcher.java   
public List<JsonObject> nextPage() throws IOException, DeserializationException {
    if (RELATIVE_LINK_NOT_FOUND.equals(nextPageUrl)) {
        throw new IllegalStateException("GitHub API no more issues to fetch");
    }
    URL url = new URL(nextPageUrl);
    LOG.info("GitHub API querying page {}", queryParamValue(url, "page"));
    LOG.lifecycle("GET " + nextPageUrl);
    URLConnection urlConnection = url.openConnection();
    LOG.info("Established connection to GitHub API");

    String resetInLocalTime = resetLimitInLocalTimeOrEmpty(urlConnection);

    LOG.info("GitHub API rate info => Remaining : {}, Limit : {}, Reset at: {}",
            urlConnection.getHeaderField("X-RateLimit-Remaining"),
            urlConnection.getHeaderField("X-RateLimit-Limit"),
            resetInLocalTime);
    nextPageUrl = extractRelativeLink(urlConnection.getHeaderField("Link"), "next");

    return parseJsonFrom(urlConnection);
}
项目:sonar-stash    文件:StashClient.java   
private static JsonObject extractResponse(Response response) throws StashClientException {
  PeekableInputStream bodyStream = new PeekableInputStream(response.getResponseBodyAsStream());

  try {
    if (!bodyStream.peek().isPresent()) {
      return null;
    }
    String contentType = response.getHeader("Content-Type");
    if (!JSON.match(contentType.trim())) {
      throw new StashClientException("Received response with type " + contentType + " instead of JSON");
    }
    Reader body = new InputStreamReader(bodyStream);
    Object obj = Jsoner.deserialize(body);
    return (JsonObject)obj;
  } catch (DeserializationException | ClassCastException | IOException e) {
    throw new StashClientException("Could not parse JSON response: " + e, e);
  }
}
项目:shipkit    文件:ReleaseNotesSerializer.java   
public Collection<ReleaseNotesData> deserialize(String jsonData) {
    try {
        final JsonArray jsonArray = (JsonArray) Jsoner.deserialize(jsonData);
        return deserialize(jsonArray);
    } catch (DeserializationException e) {
        throw new RuntimeException("Can't deserialize JSON: " + jsonData, e);
    }
}
项目:shipkit    文件:GitCommitSerializer.java   
public GitCommit deserialize(String jsonData) {
    try {
        final JsonObject jsonObject = (JsonObject) Jsoner.deserialize(jsonData);
        return deserialize(jsonObject);
    } catch (DeserializationException e) {
        throw new RuntimeException("Can't deserialize JSON: " + jsonData, e);
    }
}
项目:shipkit    文件:DefaultContributionSetSerializer.java   
public DefaultContributionSet deserialize(String jsonData) {
    try {
        final JsonObject jsonObject = (JsonObject) Jsoner.deserialize(jsonData);
        return deserialize(jsonObject);
    } catch (DeserializationException e) {
        throw new RuntimeException("Can't deserialize JSON: " + jsonData, e);
    }
}
项目:shipkit    文件:DefaultImprovementSerializer.java   
public DefaultImprovement deserialize(String jsonData) {
    try {
        final JsonObject jsonObject = (JsonObject) Jsoner.deserialize(jsonData);
        return deserialize(jsonObject);
    } catch (DeserializationException e) {
        throw new RuntimeException("Can't deserialize JSON: " + jsonData, e);
    }
}
项目:shipkit    文件:GitHubContributorsFetcher.java   
private Set<ProjectContributor> extractContributors(List<JsonObject> page, final String readOnlyAuthToken) throws IOException, DeserializationException {
    //Since returned contributor does not have 'name' element, we need to fetch the user data to get his name
    //TODO (maybe) add static caching of this. Names don't change that often, let's just cache this forever in build cache.
    GitHubObjectFetcher objectFetcher = new GitHubObjectFetcher(readOnlyAuthToken);
    Function<JsonObject, ProjectContributor> projectContributorFetcherFunction = new ProjectContributorFetcherFunction(objectFetcher);

    return new ConcurrentDispatcher().dispatch(projectContributorFetcherFunction, page);
}
项目:shipkit    文件:GitHubObjectFetcher.java   
public JsonObject getPage(String pageUrl) throws IOException, DeserializationException {
    URL url = new URL(String.format("%s%s%s", pageUrl, "?access_token=", authToken));
    LOG.info("GitHub API querying page {}", url);
    LOG.lifecycle("GET {}", url);
    URLConnection urlConnection = url.openConnection();

    String resetInLocalTime = resetLimitInLocalTimeOrEmpty(urlConnection);

    LOG.info("GitHub API rate info => Remaining : {}, Limit : {}, Reset at: {}",
            urlConnection.getHeaderField("X-RateLimit-Remaining"),
            urlConnection.getHeaderField("X-RateLimit-Limit"),
            resetInLocalTime);

    return parseJsonFrom(urlConnection);
}
项目:shipkit    文件:GitHubObjectFetcher.java   
private JsonObject parseJsonFrom(URLConnection urlConnection) throws IOException, DeserializationException {
    InputStream response = urlConnection.getInputStream();

    String content = IOUtil.readFully(response);
    LOG.info("GitHub API responded successfully.");

    return (JsonObject) Jsoner.deserialize(content);
}
项目:shipkit    文件:GitHubListFetcher.java   
private List<JsonObject> parseJsonFrom(URLConnection urlConnection) throws IOException, DeserializationException {
    InputStream response = urlConnection.getInputStream();

    LOG.info("Reading remote stream from GitHub API");
    String content = IOUtil.readFully(response);
    LOG.info("GitHub API responded successfully.");
    @SuppressWarnings("unchecked")
    List<JsonObject> issues = (List<JsonObject>) Jsoner.deserialize(content);
    LOG.info("GitHub API returned {} Json objects.", issues.size());
    return issues;
}
项目:sonar-coverage-evolution    文件:DefaultSonarClientTest.java   
private JsonObject readJsonResource(String name) throws DeserializationException, IOException {
  return (JsonObject) Jsoner.deserialize(new InputStreamReader(getClass().getClassLoader().getResourceAsStream(name)));
}
项目:shipkit    文件:FindOpenPullRequestTask.java   
@TaskAction
public void findOpenPullRequest() throws IOException, DeserializationException {
    pullRequest = new FindOpenPullRequest().findOpenPullRequest(this);
}
项目:shipkit    文件:GitHubContributorsFetcher.java   
public List<JsonObject> nextPage() throws IOException, DeserializationException {
    lastFetchedPage = fetcher.nextPage();
    return lastFetchedPage;
}
项目:shipkit    文件:RecentContributorsFetcher.java   
List<JsonObject> nextPage() throws IOException, DeserializationException {
    lastFetchedPage = fetcher.nextPage();
    return lastFetchedPage;
}
项目:shipkit    文件:GitHubTicketFetcher.java   
List<JsonObject> nextPage() throws IOException, DeserializationException {
    return fetcher.nextPage();
}