当前位置: 首页>>代码示例>>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;未经允许,请勿转载。