當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonParseException.getMessage方法代碼示例

本文整理匯總了Java中com.google.gson.JsonParseException.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonParseException.getMessage方法的具體用法?Java JsonParseException.getMessage怎麽用?Java JsonParseException.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gson.JsonParseException的用法示例。


在下文中一共展示了JsonParseException.getMessage方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deserialize

import com.google.gson.JsonParseException; //導入方法依賴的package包/類
public static Object deserialize(String json, String containerType, Class cls) throws ApiException {
  try{
    if("list".equalsIgnoreCase(containerType) || "array".equalsIgnoreCase(containerType)) {
      return JsonUtil.deserializeToList(json, cls);
    }
    else if(String.class.equals(cls)) {
      if(json != null && json.startsWith("\"") && json.endsWith("\"") && json.length() > 1)
        return json.substring(1, json.length() - 1);
      else
        return json;
    }
    else {
      return JsonUtil.deserializeToObject(json, cls);
    }
  }
  catch (JsonParseException e) {
    throw new ApiException(500, e.getMessage());
  }
}
 
開發者ID:wondenge,項目名稱:payments-Android-SDK,代碼行數:20,代碼來源:ApiInvoker.java

示例2: parseFormattedText

import com.google.gson.JsonParseException; //導入方法依賴的package包/類
/**
 * Parse a piece of formatted text, which can be either plain text with legacy
 * formatting codes, or JSON chat components.
 */
public static BaseComponent parseFormattedText(@Nullable Node node, BaseComponent def) throws InvalidXMLException {
    if(node == null) return def;

    // <blah translate="x"/> is shorthand for <blah>{"translate":"x"}</blah>
    if(node.isElement()) {
        final Attribute translate = node.asElement().getAttribute("translate");
        if(translate != null) {
            return new TranslatableComponent(translate.getValue());
        }
    }

    String text = node.getValueNormalize();
    if(looksLikeJson(text)) {
        try {
            return Components.concat(ComponentSerializer.parse(node.getValue()));
        } catch(JsonParseException e) {
            throw new InvalidXMLException(e.getMessage(), node, e);
        }
    } else {
        return Components.concat(TextComponent.fromLegacyText(BukkitUtils.colorize(text)));
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:27,代碼來源:XMLUtils.java

示例3: readTypeToken

import com.google.gson.JsonParseException; //導入方法依賴的package包/類
private Object readTypeToken(TypeToken<?> token, HttpInputMessage inputMessage) throws IOException {
  InputStreamReader json = new InputStreamReader(inputMessage.getBody(), this.getCharset(inputMessage.getHeaders()));
  try {
    return this.gson.fromJson(json, token.getType());
  } catch (JsonParseException var5) {
    throw new HttpMessageNotReadableException("JSON parse error: " + var5.getMessage(), var5);
  }
}
 
開發者ID:Huawei,項目名稱:Server_Management_Common_eSightApi,代碼行數:9,代碼來源:GsonHttpMessageConverter.java

示例4: handleResponse

import com.google.gson.JsonParseException; //導入方法依賴的package包/類
@Override
public AuthenticationResponse handleResponse(final HttpResponse response) throws IOException {
    if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
        Charset charset = HTTP.DEF_CONTENT_CHARSET;
        ContentType contentType = ContentType.get(response.getEntity());
        if(contentType != null) {
            if(contentType.getCharset() != null) {
                charset = contentType.getCharset();
            }
        }
        try {
            final JsonParser parser = new JsonParser();
            final JsonObject json = parser.parse(new InputStreamReader(response.getEntity().getContent(), charset)).getAsJsonObject();
            final String token = json.getAsJsonPrimitive("token").getAsString();
            final String endpoint = json.getAsJsonPrimitive("endpoint").getAsString();
            return new AuthenticationResponse(response, token,
                    Collections.singleton(new Region(null, URI.create(endpoint), null, true)));
        }
        catch(JsonParseException e) {
            throw new IOException(e.getMessage(), e);
        }
    }
    else if(response.getStatusLine().getStatusCode() == HttpStatus.SC_UNAUTHORIZED
            || response.getStatusLine().getStatusCode() == HttpStatus.SC_FORBIDDEN) {
        throw new AuthorizationException(new Response(response));
    }
    throw new GenericException(new Response(response));
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:29,代碼來源:HubicAuthenticationResponseHandler.java

示例5: readObject

import com.google.gson.JsonParseException; //導入方法依賴的package包/類
private Object readObject(HttpInputMessage inputMessage, TypeToken<?> token) throws IOException {
    try (Reader json = new InputStreamReader(inputMessage.getBody(), getCharset(inputMessage.getHeaders()))) {
        return this.gsonForReader.fromJson(json, token.getType());
    } catch (JsonParseException ex) {
        throw new HttpMessageNotReadableException("JSON parse error: " + ex.getMessage(), ex);
    }
}
 
開發者ID:FlowCI,項目名稱:flow-platform,代碼行數:8,代碼來源:RawGsonMessageConverter.java

示例6: convertJsonToReportPojos

import com.google.gson.JsonParseException; //導入方法依賴的package包/類
public Report[] convertJsonToReportPojos(final String json) throws CluecumberPluginException {
    Report[] reports = null;
    try {
        reports = gsonParser.fromJson(json, Report[].class);
    } catch (JsonParseException e) {
        throw new CluecumberPluginException(e.getMessage());
    }
    return reports;
}
 
開發者ID:trivago,項目名稱:cluecumber-report-plugin,代碼行數:10,代碼來源:JsonPojoConverter.java


注:本文中的com.google.gson.JsonParseException.getMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。