public String getAvroSchema(final String schemaFilePath) { try { final byte[] jsonData = Files.readAllBytes(Paths.get(schemaFilePath)); final ObjectMapper objectMapper = new ObjectMapper(); final JsonNode root = objectMapper.readTree(jsonData); return root.toString(); } catch (final JsonParseException e) { throw new KsqlException( "Could not parse the avro schema file. Details: " + e.getMessage(), e ); } catch (final IOException e) { throw new KsqlException("Could not read the avro schema file. Details: " + e.getMessage(), e); } }
public static Object readJson( String json ) throws JsonParseException { try { return OBJECT_MAPPER.readValue( json, Object.class ); } catch ( org.codehaus.jackson.JsonParseException e ) { String message = e.getMessage().split( "\\r?\\n" )[0]; JsonLocation location = e.getLocation(); throw new JsonParseException( String.format( "%s [line: %d, column: %d]", message, location.getLineNr(), location.getColumnNr() ), e ); } catch ( IOException e ) { throw new JsonParseException( e ); } }
} catch(JsonParseException e) { throw new VoldemortException("JSON parsing exception while trying to parse GET response " + e.getMessage(), e); } catch(JsonMappingException e) {
public static String indentJSON(final String jsonIn) throws JSONParseException{ JsonFactory fac = new JsonFactory(); try{ JsonParser parser = fac.createJsonParser(new StringReader(jsonIn)); JsonNode node = null; try{ node = jsonObjMapper.readTree(parser); } catch(JsonParseException ex){ throw new JSONParseException(ex.getMessage()); } StringWriter out = new StringWriter(); // Create pretty printer: JsonGenerator gen = fac.createJsonGenerator(out); DefaultPrettyPrinter pp = new DefaultPrettyPrinter(); pp.indentArraysWith(new DefaultPrettyPrinter.Lf2SpacesIndenter()); gen.setPrettyPrinter(pp); // Now write: jsonObjMapper.writeTree(gen, node); gen.flush(); gen.close(); return out.toString(); } catch(IOException ex){ LOG.log(Level.SEVERE, null, ex); } return jsonIn; }
} catch(JsonParseException e) { throw new VoldemortException("JSON parsing exception while trying to parse GET response " + e.getMessage(), e); } catch(JsonMappingException e) {
log.error(e.getMessage()); } catch (JsonMappingException e) { log.error(e.getMessage());
} catch (JsonParseException e){ log.debug(String.format("Exception %s", e.toString())); response = String.format("Invalid Data: %s", e.getMessage()); DefaultHandler.sendErrorResponse(ctx, request, response, HttpResponseStatus.BAD_REQUEST); } catch (InvalidDataException e) {
log.error(e.getMessage()); } catch (JsonMappingException e) { log.error(e.getMessage());
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; }
/** * 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, Class<T> clazz) {
@Override public Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { JavaType javaType = getJavaType(clazz); try { return this.objectMapper.readValue(inputMessage.getBody(), javaType); } catch (JsonParseException ex) { throw new HttpMessageNotReadableException("Could not read JSON: " + ex.getMessage(), ex); } }
public static Object readJson( String json ) throws JsonParseException { try { return OBJECT_MAPPER.readValue( json, Object.class ); } catch ( org.codehaus.jackson.JsonParseException e ) { String message = e.getMessage().split( "\\r?\\n" )[0]; JsonLocation location = e.getLocation(); throw new JsonParseException( String.format( "%s [line: %d, column: %d]", message, location.getLineNr(), location.getColumnNr() ), e ); } catch ( IOException e ) { throw new JsonParseException( e ); } }
LOG.error("WARCIndexerMapper.configure(): " + e.getMessage()); } catch (JsonParseException e) { LOG.error("WARCIndexerMapper.configure(): " + e.getMessage()); } catch (JsonMappingException e) { LOG.error("WARCIndexerMapper.configure(): " + e.getMessage());
LOG.error("WARCIndexerMapper.configure(): " + e.getMessage()); } catch (JsonParseException e) { LOG.error("WARCIndexerMapper.configure(): " + e.getMessage()); } catch (JsonMappingException e) { LOG.error("WARCIndexerMapper.configure(): " + e.getMessage());
public Network fetchHomeNetwork(Alfresco alfresco) { Network homeNetwork = null; try { homeNetwork = alfresco.getHomeNetwork(); } catch (JsonParseException e) { throw new AlfrescoException(e.getMessage(), e); } catch (JsonMappingException e) { throw new AlfrescoException(e.getMessage(), e); } catch (IOException e) { throw new AlfrescoException(e.getMessage(), e); } return homeNetwork; }
public void setConnectionValues(Alfresco alfresco, ConnectionValues values) { try { Person currentUser = alfresco.getCurrentUser(); values.setDisplayName(currentUser.getFirstName() + " " + currentUser.getLastName()); values.setProviderUserId(currentUser.getId()); } catch (JsonParseException e) { throw new AlfrescoException(e.getMessage(), e); } catch (JsonMappingException e) { throw new AlfrescoException(e.getMessage(), e); } catch (IOException e) { throw new AlfrescoException(e.getMessage(), e); } }
private void dump(Plan p) { try { OptimizedPlan op = compileNoStats(p); PlanJSONDumpGenerator dumper = new PlanJSONDumpGenerator(); String json = dumper.getOptimizerPlanAsJSON(op); JsonParser parser = new JsonFactory().createJsonParser(json); while (parser.nextToken() != null); } catch (JsonParseException e) { e.printStackTrace(); Assert.fail("JSON Generator produced malformatted output: " + e.getMessage()); } catch (Exception e) { e.printStackTrace(); Assert.fail("An error occurred in the test: " + e.getMessage()); } } }
private void dump(Plan p) { try { List<DataSinkNode> sinks = PactCompiler.createPreOptimizedPlan(p); PlanJSONDumpGenerator dumper = new PlanJSONDumpGenerator(); String json = dumper.getPactPlanAsJSON(sinks); JsonParser parser = new JsonFactory().createJsonParser(json); while (parser.nextToken() != null); } catch (JsonParseException e) { e.printStackTrace(); Assert.fail("JSON Generator produced malformatted output: " + e.getMessage()); } catch (Exception e) { e.printStackTrace(); Assert.fail("An error occurred in the test: " + e.getMessage()); } } }
public UserProfile fetchUserProfile(Alfresco alfresco) { UserProfileBuilder userProfile = new UserProfileBuilder(); try { Person currentUser = alfresco.getCurrentUser(); userProfile.setEmail(currentUser.getEmail()).setFirstName(currentUser.getFirstName()).setLastName(currentUser.getLastName()).setUsername(currentUser.getId()); } catch (JsonParseException e) { throw new AlfrescoException(e.getMessage(), e); } catch (JsonMappingException e) { throw new AlfrescoException(e.getMessage(), e); } catch (IOException e) { throw new AlfrescoException(e.getMessage(), e); } return userProfile.build(); }
} catch (JsonParseException e) { status.setResponseCode(Status.OTHER_ERROR_CODE, e.getMessage()); } catch (IOException e) {