javax.json.JsonException.getMessage()方法的使用及代码示例

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

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

JsonException.getMessage介绍

暂无

代码示例

代码示例来源:origin: org.pageseeder.berlioz/pso-berlioz

/**
 * Always return a JSON Writer.
 *
 * @return The JSON writer to use.
 *
 * @throws UnsupportedOperationException if no provider could be found.
 */
private static synchronized JsonGeneratorFactory loadFactory() {
 try {
  // This method does not return null, it throws a JsonException instead
  JsonProvider provider = JsonProvider.provider();
  LOGGER.debug("JSON Provider found using {}", provider.getClass().getName());
  // XXX: We could supply configuration for the factory
  return provider.createGeneratorFactory(Collections.emptyMap());
 } catch (JsonException ex) {
  LOGGER.warn("JSON Provider not found: {}", ex.getMessage());
  throw new UnsupportedOperationException("Unable to find suitable provider");
 }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.jcr.contentloader

@Override
public void parse(InputStream ins, ContentCreator contentCreator) throws IOException, RepositoryException {
  try {
    String jsonString = toString(ins).trim();
    if (!jsonString.startsWith("{")) {
      jsonString = "{" + jsonString + "}";
    }
    Map<String, Object> config = new HashMap<>();
    config.put("org.apache.johnzon.supports-comments", true);
    JsonObject json = Json.createReaderFactory(config).createReader(new StringReader(tickToDoubleQuote(jsonString))).readObject();
    this.createNode(null, json, contentCreator);
  } catch (JsonException je) {
    throw (IOException) new IOException(je.getMessage()).initCause(je);
  }
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-extras

@Override
public ByteBuffer serialize(JsonStructure value, ProtocolVersion protocolVersion)
  throws InvalidTypeException {
 if (value == null) return null;
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 try {
  JsonWriter writer = writerFactory.createWriter(baos);
  writer.write(value);
  return ByteBuffer.wrap(baos.toByteArray());
 } catch (JsonException e) {
  throw new InvalidTypeException(e.getMessage(), e);
 } finally {
  try {
   baos.close();
  } catch (IOException e) {
   // cannot happen
   throw new InvalidTypeException(e.getMessage(), e);
  }
 }
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-extras

@Override
public String format(JsonStructure value) throws InvalidTypeException {
 if (value == null) return "NULL";
 String json;
 StringWriter sw = new StringWriter();
 try {
  JsonWriter writer = writerFactory.createWriter(sw);
  writer.write(value);
  json = sw.toString();
 } catch (JsonException e) {
  throw new InvalidTypeException(e.getMessage(), e);
 } finally {
  try {
   sw.close();
  } catch (IOException e) {
   // cannot happen
   throw new InvalidTypeException(e.getMessage(), e);
  }
 }
 return ParseUtils.quote(json);
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-extras

@Override
 @SuppressWarnings("unchecked")
 public JsonStructure parse(String value) throws InvalidTypeException {
  if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL")) return null;
  if (!ParseUtils.isQuoted(value))
   throw new InvalidTypeException("JSON strings must be enclosed by single quotes");
  String json = ParseUtils.unquote(value);
  StringReader sr = new StringReader(json);
  try {
   JsonReader reader = readerFactory.createReader(sr);
   return reader.read();
  } catch (JsonException e) {
   throw new InvalidTypeException(e.getMessage(), e);
  } finally {
   sr.close();
  }
 }
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-extras

@Override
@SuppressWarnings("unchecked")
public JsonStructure deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion)
  throws InvalidTypeException {
 if (bytes == null) return null;
 ByteArrayInputStream bais = new ByteArrayInputStream(Bytes.getArray(bytes));
 try {
  JsonReader reader = readerFactory.createReader(bais);
  return reader.read();
 } catch (JsonException e) {
  throw new InvalidTypeException(e.getMessage(), e);
 } finally {
  try {
   bais.close();
  } catch (IOException e) {
   // cannot happen
   throw new InvalidTypeException(e.getMessage(), e);
  }
 }
}

代码示例来源:origin: org.apache.sling/org.apache.sling.discovery.base

throw new IOException("Unable to Encrypt Message " + e.getMessage());
} catch (JsonException e) {
  throw new IOException("Unable to Encrypt Message " + e.getMessage());
} catch (InvalidKeySpecException e) {
  throw new IOException("Unable to Encrypt Message " + e.getMessage());

相关文章