/** * string --> bean、Map、List(array) * * @param jsonStr * @param clazz * @return obj * @throws Exception */ public static <T> T readValue(String jsonStr, Class<T> clazz) { try { return getInstance().readValue(jsonStr, clazz); } catch (JsonParseException e) { logger.error(e.getMessage(), e); } catch (JsonMappingException e) { logger.error(e.getMessage(), e); } catch (IOException e) { logger.error(e.getMessage(), e); } return null; }
/** * string --> List<Bean>... * * @param jsonStr * @param parametrized * @param parameterClasses * @param <T> * @return */ public static <T> T readValue(String jsonStr, Class<?> parametrized, Class<?>... parameterClasses) { try { JavaType javaType = getInstance().getTypeFactory().constructParametricType(parametrized, parameterClasses); return getInstance().readValue(jsonStr, javaType); } catch (JsonParseException e) { logger.error(e.getMessage(), e); } catch (JsonMappingException e) { logger.error(e.getMessage(), e); } catch (IOException e) { logger.error(e.getMessage(), e); } return null; }
private CubeDesc deserializeCubeDesc(CubeRequest cubeRequest) { CubeDesc desc = null; try { logger.debug("Saving cube " + cubeRequest.getCubeDescData()); desc = JsonUtil.readValue(cubeRequest.getCubeDescData(), CubeDesc.class); } catch (JsonParseException e) { logger.error("The cube definition is not valid.", e); updateRequest(cubeRequest, false, e.getMessage()); } catch (JsonMappingException e) { logger.error("The cube definition is not valid.", e); updateRequest(cubeRequest, false, e.getMessage()); } catch (IOException e) { logger.error("Failed to deal with the request.", e); throw new InternalErrorException("Failed to deal with the request:" + e.getMessage(), e); } return desc; }
private DataModelDesc deserializeDataModelDesc(ModelRequest modelRequest) { DataModelDesc desc = null; try { logger.debug("Saving MODEL " + modelRequest.getModelDescData()); desc = JsonUtil.readValue(modelRequest.getModelDescData(), DataModelDesc.class); } catch (JsonParseException e) { logger.error("The data model definition is not valid.", e); updateRequest(modelRequest, false, e.getMessage()); } catch (JsonMappingException e) { logger.error("The data model definition is not valid.", e); updateRequest(modelRequest, false, e.getMessage()); } catch (IOException e) { logger.error("Failed to deal with the request.", e); throw new InternalErrorException("Failed to deal with the request:" + e.getMessage(), e); } return desc; }
private StreamingConfig deserializeSchemalDesc(StreamingRequest streamingRequest) { StreamingConfig desc = null; try { logger.debug("Saving StreamingConfig " + streamingRequest.getStreamingConfig()); desc = JsonUtil.readValue(streamingRequest.getStreamingConfig(), StreamingConfig.class); updateRequest(streamingRequest, true, null); } catch (JsonParseException e) { logger.error("The StreamingConfig definition is invalid.", e); updateRequest(streamingRequest, false, e.getMessage()); } catch (JsonMappingException e) { logger.error("The data StreamingConfig definition is invalid.", e); updateRequest(streamingRequest, false, e.getMessage()); } catch (IOException e) { logger.error("Failed to deal with the request.", e); throw new InternalErrorException("Failed to deal with the request:" + e.getMessage(), e); } return desc; }
private KafkaConfig deserializeKafkaSchemalDesc(StreamingRequest streamingRequest) { KafkaConfig desc = null; try { logger.debug("Saving KafkaConfig " + streamingRequest.getKafkaConfig()); desc = JsonUtil.readValue(streamingRequest.getKafkaConfig(), KafkaConfig.class); updateRequest(streamingRequest, true, null); } catch (JsonParseException e) { logger.error("The KafkaConfig definition is invalid.", e); updateRequest(streamingRequest, false, e.getMessage()); } catch (JsonMappingException e) { logger.error("The data KafkaConfig definition is invalid.", e); updateRequest(streamingRequest, false, e.getMessage()); } catch (IOException e) { logger.error("Failed to deal with the request.", e); throw new InternalErrorException("Failed to deal with the request:" + e.getMessage(), e); } return desc; }
logger.error("Bad mesage? " + e.getMessage(), e); queue.ack(Arrays.asList(msg));
} catch (Exception attrE) { final String msg = String.format("Cached value for %s was not a serialized Signal nor FlowFileAttributes. Error messages: \"%s\", \"%s\"", signalId, jsonE.getMessage(), attrE.getMessage()); throw new DeserializationException(msg);
@Override public T build(ConfigurationSourceProvider provider, String path) throws IOException, ConfigurationException { try (InputStream input = provider.open(requireNonNull(path))) { final JsonNode node = mapper.readTree(createParser(input)); if (node == null) { throw ConfigurationParsingException .builder("Configuration at " + path + " must not be empty") .build(path); } return build(node, path); } catch (JsonParseException e) { throw ConfigurationParsingException .builder("Malformed " + formatName) .setCause(e) .setLocation(e.getLocation()) .setDetail(e.getMessage()) .build(path); } }
private TableDesc deserializeTableDesc(StreamingRequest streamingRequest) { TableDesc desc = null; try { logger.debug("Saving TableDesc " + streamingRequest.getTableData()); desc = JsonUtil.readValue(streamingRequest.getTableData(), TableDesc.class); updateRequest(streamingRequest, true, null); } catch (JsonParseException e) { logger.error("The TableDesc definition is invalid.", e); updateRequest(streamingRequest, false, e.getMessage()); } catch (JsonMappingException e) { logger.error("The data TableDesc definition is invalid.", e); updateRequest(streamingRequest, false, e.getMessage()); } catch (IOException e) { logger.error("Failed to deal with the request.", e); throw new InternalErrorException("Failed to deal with the request:" + e.getMessage(), e); } if (null != desc) { String[] dbTable = HadoopUtil.parseHiveTableName(desc.getName()); desc.setName(dbTable[1]); desc.setDatabase(dbTable[0]); desc.getIdentity(); } return desc; }
@Override public Response toResponse(JsonParseException exception) { return Response.status(Response.Status.BAD_REQUEST).entity(exception.getMessage()).type("text/plain").build(); } }
public static <T> T readValueRefer(String jsonStr, TypeReference typeReference) { try { return getInstance().readValue(jsonStr, typeReference); // new TypeReference<T>() { } } catch (JsonParseException e) { logger.error(e.getMessage(), e); } catch (JsonMappingException e) { logger.error(e.getMessage(), e); } catch (IOException e) { logger.error(e.getMessage(), e); } return null; }
/** * string --> bean、Map、List(array) * * @param jsonStr * @param clazz * @return obj * @throws Exception */ public static <T> T readValue(String jsonStr, Class<T> clazz) { try { return getInstance().readValue(jsonStr, clazz); } catch (JsonParseException e) { logger.error(e.getMessage(), e); } catch (JsonMappingException e) { logger.error(e.getMessage(), e); } catch (IOException e) { logger.error(e.getMessage(), e); } return null; } public static <T> T readValueRefer(String jsonStr, TypeReference typeReference) {
return null; } catch (JsonParseException e) { log.error(e.getMessage()); } catch (JsonMappingException e) { log.error(e.getMessage());
return null; } catch (JsonParseException e) { log.error(e.getMessage()); } catch (JsonMappingException e) { log.error(e.getMessage());
return null; } catch (JsonParseException e) { log.error("Error during translation, Caused by:" + e.getMessage() + ", returning null"); return null; } catch (JsonMappingException e) {
} catch (JsonParseException jpex) { System.out.println("Error. Something went wrong trying to parse json data: #<#<"+jsonData+ ">#># or json schema: @<@<"+jsonSchema+">@>@. Are the double quotes included? "+jpex.getMessage());
@Override public Response toResponse(JsonParseException exception) { return Response.status(Response.Status.BAD_REQUEST).entity(exception.getMessage()).type("text/plain").build(); } }
public ConfigValue getConfigValue() throws Exception { byte[] value = curator.getData().forPath(zkPath); ConfigValue v; try { v = mapper.readValue(value, ConfigValue.class); } catch (JsonParseException e) { LOG.warn("warn getConfigValue parse exception", e.getMessage()); v = new ConfigValue(); } return v; } }
public static <T> T readValueRefer(String jsonStr, Class<T> clazz) { try { return getInstance().readValue(jsonStr, new TypeReference<T>() { }); } catch (JsonParseException e) { logger.error(e.getMessage(), e); } catch (JsonMappingException e) { logger.error(e.getMessage(), e); } catch (IOException e) { logger.error(e.getMessage(), e); } return null; }