com.fasterxml.jackson.core.JsonParseException Java Examples
The following examples show how to use
com.fasterxml.jackson.core.JsonParseException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BodyParam.java From blynk-server with GNU General Public License v3.0 | 6 votes |
@Override public Object get(ChannelHandlerContext ctx, URIDecoder uriDecoder) { if (uriDecoder.contentType == null || !uriDecoder.contentType.contains(expectedContentType)) { throw new RuntimeException("Unexpected content type. Expecting " + expectedContentType + "."); } switch (expectedContentType) { case MediaType.APPLICATION_JSON : String data = ""; try { data = uriDecoder.getContentAsString(); return JsonParser.MAPPER.readValue(data, type); } catch (JsonParseException | JsonMappingException jsonParseError) { log.debug("Error parsing body param : '{}'.", data); throw new RuntimeException("Error parsing body param. " + data); } catch (Exception e) { log.error("Unexpected error during parsing body param.", e); throw new RuntimeException("Unexpected error during parsing body param.", e); } default : return uriDecoder.getContentAsString(); } }
Example #2
Source File: RepeatingRecordDefinitionConfigurationCreatingConsumerTest.java From baleen with Apache License 2.0 | 6 votes |
private void checkDefinitions() throws IOException, JsonParseException, JsonMappingException { Path yamlFile = getDefinitionPath(); List<TemplateRecordConfiguration> definitions = readDefinitions(yamlFile); TemplateRecordConfiguration record = assertNamedRecord(definitions); assertTrue(record.isRepeat()); assertNull(record.getMinimalRepeat()); assertEquals( ImmutableList.of("Paragraph:nth-of-type(2)", "Paragraph:nth-of-type(3)"), record.getCoveredPaths()); assertDefaultRecord(definitions); Files.delete(yamlFile); }
Example #3
Source File: ZhcxController.java From danyuan-application with Apache License 2.0 | 6 votes |
@RequestMapping(path = "/findAllTableRow", method = { RequestMethod.GET, RequestMethod.POST }) public @JsonIgnore Map<String, Object> findAllTableRow(@RequestBody SysDbmsTabsColsInfoVo vo) throws JsonParseException, JsonMappingException, IOException { logger.info("findAllTableRow", ZhcxController.class); Map<String, Object> map = new HashMap<>(); if ("oracle".equals(vo.getDbType()) || "mysql".equals(vo.getDbType())) { // if ("单表多条件查询".equals(vo.getType())) { // map = zhcxService.findAllSigleTableByMulteityParam(vo); // } else if ("一键查询单表多个不同索引拼接".equals(vo.getType()) || "单表多条件更多查询".equals(vo.getType())) { // 一键查询单表多个不同索引拼接 map = zhcxService.findBySingleTableByGroupsAndMulteityParam(vo); // } } else if ("elastic".equals(vo.getDbType())) { // // elasticsearch // map = zhcxService.findByElasticsearchByGroupsAndMulteityParam(vo); } return map; }
Example #4
Source File: JsonToGuavaMultimap.java From levelup-java-examples with Apache License 2.0 | 6 votes |
@Test public void convert() throws JsonParseException, JsonMappingException, JsonProcessingException, IOException { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.registerModule(new GuavaModule()); Multimap<String, NavItem> navs = objectMapper.readValue( objectMapper.treeAsTokens(objectMapper.readTree(jsonString)), objectMapper.getTypeFactory().constructMapLikeType( Multimap.class, String.class, NavItem.class)); logger.info(navs); assertThat(navs.keys(), hasItems("123455", "999999")); }
Example #5
Source File: RamlJavaClientGenerator.java From raml-java-client-generator with Apache License 2.0 | 6 votes |
public JType generatePojoFromSchema(JCodeModel codeModel, String className, String packageName, String json, String url, SourceType sourceType) throws IOException { try { SchemaMapper schemaMapper = new SchemaMapper(getRuleFactory(sourceType, codeGenConfig), new SchemaGenerator()); if (SourceType.JSON == sourceType) { return schemaMapper.generate(codeModel, className, packageName, json); } else { URI uri; if (url == null) { File tmpFile = File.createTempFile("tmp", "json"); try (FileWriter writer = new FileWriter(tmpFile)) { writer.write(json); } uri = tmpFile.toURI(); } else { uri = URI.create(url); } return schemaMapper.generate(codeModel, className, packageName, json, uri); } } catch (JsonParseException e) { logger.info("Can not generate " + className + " from schema since : " + e.getMessage()); return codeModel.ref(String.class); } }
Example #6
Source File: PortMap.java From enmasse with Apache License 2.0 | 6 votes |
@Override public Map<String, Integer> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { if (p.currentToken() == JsonToken.VALUE_NULL) { return null; } if (p.currentToken() != JsonToken.START_ARRAY) { throw new JsonParseException(p, "Expected start of array"); } p.nextToken(); if (p.currentToken() == JsonToken.END_ARRAY) { return new HashMap<> (); } final Map<String, Integer> result = new HashMap<>(); final Iterator<Mapping> i = p.readValuesAs(Mapping.class); i.forEachRemaining(m -> result.put(m.getName(), m.getPort())); return result; }
Example #7
Source File: TestJSonToGeomFromWkiOrWkt_CR177613.java From geometry-api-java with Apache License 2.0 | 6 votes |
public static int fromJsonToWkid(JsonParser parser) throws JsonParseException, IOException { int wkid = 0; if (parser.getCurrentToken() != JsonToken.START_OBJECT) { return 0; } while (parser.nextToken() != JsonToken.END_OBJECT) { String fieldName = parser.getCurrentName(); if ("wkid".equals(fieldName)) { parser.nextToken(); wkid = parser.getIntValue(); } } return wkid; }
Example #8
Source File: SendGridHttpTest.java From ogham with Apache License 2.0 | 6 votes |
@Test public void simpleEmail() throws MessagingException, JsonParseException, JsonMappingException, IOException { // @formatter:off server.stubFor(post("/v3/mail/send") .willReturn(aResponse().withStatus(202))); // @formatter:on // @formatter:off Email email = new Email() .subject(SUBJECT) .content(CONTENT_TEXT) .from(FROM_ADDRESS) .to(TO_ADDRESS_1); // @formatter:on messagingService.send(email); // @formatter:off server.verify(postRequestedFor(urlEqualTo("/v3/mail/send")) .withRequestBody(equalToJson(resourceAsString("/expected/requests/simpleEmail.json"), true, true))); // @formatter:on }
Example #9
Source File: JsonMessageConverterTest.java From sailfish-core with Apache License 2.0 | 6 votes |
@Test public void testFullFormatRejected() throws JsonParseException, IOException, SailfishURIException { IMessage message = generate(); message.getMetaData().setRejectReason("Test reject"); String json = JsonMessageConverter.toJson(message, false); IMessage actual = JsonMessageConverter.fromJson(json, false); compare(message, actual, 43, 0, 0); Assert.assertEquals("Test reject", actual.getMetaData().getRejectReason()); Assert.assertTrue(actual.getMetaData().isRejected()); json = JsonMessageConverter.toJson(message, dictionary, false); actual = JsonMessageConverter.fromJson(json, manager, false); compare(message, actual, 43, 0, 0); Assert.assertEquals("Test reject", actual.getMetaData().getRejectReason()); Assert.assertTrue(actual.getMetaData().isRejected()); }
Example #10
Source File: AclTableMigrationTool.java From kylin with Apache License 2.0 | 6 votes |
private ManagedUser hbaseRowToUser(Result result) throws JsonParseException, JsonMappingException, IOException { if (null == result || result.isEmpty()) return null; String username = Bytes.toString(result.getRow()); byte[] valueBytes = result.getValue(Bytes.toBytes(AclConstant.USER_AUTHORITY_FAMILY), Bytes.toBytes(AclConstant.USER_AUTHORITY_COLUMN)); UserGrantedAuthority[] deserialized = ugaSerializer.deserialize(valueBytes); String password = ""; List<UserGrantedAuthority> authorities = Collections.emptyList(); // password is stored at [0] of authorities for backward compatibility if (deserialized != null) { if (deserialized.length > 0 && deserialized[0].getAuthority().startsWith(AclConstant.PWD_PREFIX)) { password = deserialized[0].getAuthority().substring(AclConstant.PWD_PREFIX.length()); authorities = Arrays.asList(deserialized).subList(1, deserialized.length); } else { authorities = Arrays.asList(deserialized); } } return new ManagedUser(username, password, false, authorities); }
Example #11
Source File: JacksonStreamTest.java From java-client-api with Apache License 2.0 | 6 votes |
private OrderItem getOrderItem(JsonParser parser) throws JsonParseException, IOException { OrderItem item = new OrderItem(); if ( parser.getCurrentToken() != JsonToken.START_OBJECT ) { throw new IllegalStateException("nextValue should have been START_OBJECT but is:[" + parser.getCurrentToken() + "]"); } while ( parser.nextValue() != null ) { if ( "productId".equals(parser.getCurrentName()) ) { item.setProductId( parser.getText() ); } else if ( "quantity".equals(parser.getCurrentName()) ) { item.setQuantity( parser.getIntValue() ); } else if ( "itemCostUSD".equals(parser.getCurrentName()) ) { item.setItemCostUSD( parser.getFloatValue() ); } if ( parser.getCurrentToken() == JsonToken.END_OBJECT ) { return item; } } return null; }
Example #12
Source File: DiffTest.java From milkman with MIT License | 6 votes |
@Test public void shouldMergeCorrectlyRenameCollection() throws JsonParseException, JsonMappingException, IOException { String colId = UUID.randomUUID().toString(); List<Collection> base = new LinkedList<Collection>(); base.add(new Collection(colId, "collection1", false, new LinkedList<>(), Collections.emptyList())); List<Collection> working = new LinkedList<Collection>(); working.add(new Collection(colId, "collection2", false, new LinkedList<>(), Collections.emptyList())); CollectionDiffer collectionDiffer = new CollectionDiffer(); DiffNode diffNode = collectionDiffer.compare(working, base); collectionDiffer.mergeDiffs(working, base, diffNode); assertThat(base.size()).isEqualTo(1); assertThat(base.get(0).getId()).isEqualTo(colId); assertThat(base.get(0).getName()).isEqualTo("collection2"); }
Example #13
Source File: SiteToSiteRestApiClient.java From nifi with Apache License 2.0 | 6 votes |
private TransactionResultEntity readResponse(final InputStream inputStream) throws IOException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); StreamUtils.copy(inputStream, bos); String responseMessage = null; try { responseMessage = new String(bos.toByteArray(), StandardCharsets.UTF_8); logger.debug("readResponse responseMessage={}", responseMessage); final ObjectMapper mapper = new ObjectMapper(); return mapper.readValue(responseMessage, TransactionResultEntity.class); } catch (JsonParseException | JsonMappingException e) { if (logger.isDebugEnabled()) { logger.debug("Failed to parse JSON.", e); } final TransactionResultEntity entity = new TransactionResultEntity(); entity.setResponseCode(ResponseCode.ABORT.getCode()); entity.setMessage(responseMessage); return entity; } }
Example #14
Source File: JsonBufferedObject.java From RedReader with GNU General Public License v3.0 | 6 votes |
@Override protected void buildBuffered(final JsonParser jp) throws IOException { JsonToken jt; while((jt = jp.nextToken()) != JsonToken.END_OBJECT) { if(jt != JsonToken.FIELD_NAME) throw new JsonParseException(jp, "Expecting field name, got " + jt.name(), jp.getCurrentLocation()); final String fieldName = jp.getCurrentName(); final JsonValue value = new JsonValue(jp); synchronized(this) { properties.put(fieldName, value); notifyAll(); } value.buildInThisThread(); } }
Example #15
Source File: BulkUploadProcess.java From sunbird-lms-service with MIT License | 5 votes |
@JsonIgnore public StorageDetails getDecryptedStorageDetails() throws JsonParseException, JsonMappingException, IOException { String rawData = getStorageDetails(); if (rawData != null) { ObjectMapper mapper = new ObjectMapper(); String decryptedData = decryptionService.decryptData(getStorageDetails()); return mapper.readValue(decryptedData, StorageDetails.class); } else { return null; } }
Example #16
Source File: JobExecutionManagerServiceImplTest.java From pacbot with Apache License 2.0 | 5 votes |
@Test public void createJobExceptionTest() throws PacManException, JsonParseException, JsonMappingException, IOException { JobDetails createJobDetails = getCreateJobDetailsRequest(); MultipartFile firstFile = getMockMultipartFile(); when(putRuleRequest.withName(anyString()).withDescription(anyString()).withState(anyString())).thenReturn(putRuleRequest); when(putRuleResult.getRuleArn()).thenReturn(null); when(amazonCloudWatchEvents.putRule(any())).thenReturn(putRuleResult); JobProperty jobProperty = buildJobProperty(); when(config.getJob()).thenReturn(jobProperty); Map<String, Object> ruleParamDetails = Maps.newHashMap(); when(mapper.readValue(anyString(), any(TypeReference.class))).thenReturn(ruleParamDetails); assertThatThrownBy(() -> jobExecutionManagerService.createJob(firstFile, createJobDetails, "user123")).isInstanceOf(PacManException.class); }
Example #17
Source File: TeapotHandler.java From example-restful-project with MIT License | 5 votes |
/** * Relays the message from the teapot to the client. */ @Override public void handleTextMessage(WebSocketSession session, TextMessage message) throws JsonParseException, JsonMappingException, IOException { // TODO: replace Jackson by custom protocole TeapotMessage msg = jacksonMapper.readValue( message.getPayload(), TeapotMessage.class); String clientId = msg.getClientId(); String payload = msg.getPayload(); char lastCharacter = payload.charAt(payload.length() - 1); /* If last character is EOT */ boolean eot = lastCharacter == EOT; /* If first chararcter is CAN */ boolean can = lastCharacter == CAN; /* Remove last character from payload if it is a control character */ if (eot || can) { payload = payload.substring(0, payload.length() - 1); } /* Canceled by teapot */ if (can) { commandService.submitError(clientId, payload); return; } commandService.submitResponse(msg.getClientId(), payload, eot); }
Example #18
Source File: RequestTest.java From seldon-server with Apache License 2.0 | 5 votes |
@Test public void testActionPatterns() throws JsonParseException, IOException { String json = "{\"consumer\":\"dailyrecord\",\"httpmethod\":\"GET\",\"path\":\"/users/22/actions\",\"exectime\":\"34\",\"time\":123456789}"; ObjectMapper mapper = new ObjectMapper(); JsonFactory factory = mapper.getFactory(); JsonParser parser = factory.createParser(json); JsonNode jNode = mapper.readTree(parser); Request r = new Request(jNode); Assert.assertNotNull(r); Assert.assertEquals("/users/{userid}/actions", r.path); }
Example #19
Source File: BeanValidation.java From open-Autoscaler with Apache License 2.0 | 5 votes |
public static JsonNode parseMetrics(String jsonString, HttpServletRequest httpServletRequest) throws JsonParseException, JsonMappingException, IOException{ List<String> violation_message = new ArrayList<String>(); ObjectNode result = new_mapper.createObjectNode(); result.put("valid", false); //JavaType javaType = getCollectionType(ArrayList.class, HistoryData.class); //new_mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); logger.info("Received metrics: " + jsonString); Metrics metrics = new_mapper.readValue(jsonString, Metrics.class); ValidatorFactory vf = Validation.buildDefaultValidatorFactory(); Locale locale = LocaleUtil.getLocale(httpServletRequest); MessageInterpolator interpolator = new LocaleSpecificMessageInterpolator(vf.getMessageInterpolator(), locale); Validator validator = vf.usingContext().messageInterpolator(interpolator).getValidator(); Set<ConstraintViolation<Metrics>> set = validator.validate(metrics); if (set.size() > 0 ){ for (ConstraintViolation<Metrics> constraintViolation : set) { violation_message.add(constraintViolation.getMessage()); } result.set("violation_message", new_mapper.valueToTree(violation_message)); return result; } //additional data manipulation String new_json = metrics.transformOutput(); result.put("valid", true); result.put("new_json", new_json); return result; }
Example #20
Source File: RequestTest.java From seldon-server with Apache License 2.0 | 5 votes |
@Test public void testActionPatterns4() throws JsonParseException, IOException { String json = "{\"consumer\":\"dailyrecord\",\"httpmethod\":\"GET\",\"path\":\"/items/22/actions/33\",\"exectime\":\"34\",\"time\":123456789}"; ObjectMapper mapper = new ObjectMapper(); JsonFactory factory = mapper.getFactory(); JsonParser parser = factory.createParser(json); JsonNode jNode = mapper.readTree(parser); Request r = new Request(jNode); Assert.assertNotNull(r); Assert.assertEquals("/items/{itemid}/actions/{userid}", r.path); }
Example #21
Source File: Serializer.java From Kylin with Apache License 2.0 | 5 votes |
public T deserialize(byte[] value) throws JsonParseException, JsonMappingException, IOException { if (null == value) { return null; } return JsonUtil.readValue(value, type); }
Example #22
Source File: BooleanDeserializer.java From govpay with GNU General Public License v3.0 | 5 votes |
@Override public Boolean deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); if(node instanceof BooleanNode) { BooleanNode bNode = (BooleanNode) node; return bNode.booleanValue(); } throw new JsonParseException(jsonParser, "il field " + jsonParser.getCurrentName() + " non e' di tipo " + Boolean.class.getName() + "."); }
Example #23
Source File: GrantByClientCredentialTest.java From demo-spring-boot-security-oauth2 with MIT License | 5 votes |
@Test public void accessProtectedResourceByJwtToken() throws JsonParseException, JsonMappingException, IOException, InvalidJwtException { ResponseEntity<String> response = new TestRestTemplate().getForEntity("http://localhost:" + port + "/resources/client", String.class); assertEquals(HttpStatus.UNAUTHORIZED, response.getStatusCode()); response = new TestRestTemplate("trusted-app", "secret").postForEntity("http://localhost:" + port + "/oauth/token?client_id=trusted-app&grant_type=client_credentials", null, String.class); String responseText = response.getBody(); assertEquals(HttpStatus.OK, response.getStatusCode()); HashMap jwtMap = new ObjectMapper().readValue(responseText, HashMap.class); String accessToken = (String) jwtMap.get("access_token"); HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", "Bearer " + accessToken); JwtContext jwtContext = jwtConsumer.process(accessToken); logJWTClaims(jwtContext); response = new TestRestTemplate().exchange("http://localhost:" + port + "/resources/principal", HttpMethod.GET, new HttpEntity<>(null, headers), String.class); assertEquals("trusted-app", response.getBody()); response = new TestRestTemplate().exchange("http://localhost:" + port + "/resources/trusted_client", HttpMethod.GET, new HttpEntity<>(null, headers), String.class); assertEquals(HttpStatus.OK, response.getStatusCode()); response = new TestRestTemplate().exchange("http://localhost:" + port + "/resources/roles", HttpMethod.GET, new HttpEntity<>(null, headers), String.class); assertEquals("[{\"authority\":\"ROLE_TRUSTED_CLIENT\"}]", response.getBody()); }
Example #24
Source File: BasicJavaClientREST.java From java-client-api with Apache License 2.0 | 5 votes |
/** * Get the expected JSON query option * * @param filename * @return * @throws JsonParseException * @throws IOException */ public JsonNode expectedJSONQueryOption(String filename) throws JsonParseException, IOException { // get json document for expected result ObjectMapper mapper = new ObjectMapper(); JsonFactory jfactory = new JsonFactory(); JsonParser jParser = jfactory.createJsonParser(new File("src/test/java/com/marklogic/client/functionaltest/queryoptions/" + filename)); JsonNode expectedDoc = mapper.readTree(jParser); return expectedDoc; }
Example #25
Source File: JsonParsingServiceImpl.java From konker-platform with Apache License 2.0 | 5 votes |
@Override public List<Map<String, Object>> toListMap(String json) throws JsonProcessingException { Optional.ofNullable(json) .filter(s -> !s.isEmpty()) .orElseThrow(() -> new IllegalArgumentException("JSON cannot be null or empty")); try { TypeFactory typeFactory = OBJECT_MAPPER.getTypeFactory(); return OBJECT_MAPPER.readValue(json, typeFactory.constructCollectionType(List.class, Map.class)); } catch (IOException e) { throw new JsonParseException("Failed to parse json",null,e); } }
Example #26
Source File: OrgBulkUploadBackgroundJobActor.java From sunbird-lms-service with MIT License | 5 votes |
private void setLocationInformation( BulkUploadProcessTask task, LocationClient locationClient, Map<String, Location> locationCache, ActorRef locationActor, List<String> locationCodes) throws IOException, JsonParseException, JsonMappingException { ObjectMapper mapper = new ObjectMapper(); if (ProjectUtil.BulkProcessStatus.COMPLETED.getValue() == task.getStatus()) { List<String> locationNames = new ArrayList<>(); for (String locationCode : locationCodes) { if (locationCache.containsKey(locationCode)) { locationNames.add(locationCache.get(locationCode).getName()); } else { Location location = locationClient.getLocationByCode(locationActor, locationCode); locationNames.add(location.getName()); } } Map<String, Object> row = mapper.readValue(task.getSuccessResult(), Map.class); if (locationNames.size() == 1) { row.put(JsonKey.LOCATION_NAME, locationNames.get(0)); row.put(JsonKey.LOCATION_CODE, locationCodes.get(0)); } else { row.put(JsonKey.LOCATION_NAME, locationNames); row.put(JsonKey.LOCATION_CODE, locationCodes); } task.setSuccessResult(mapper.writeValueAsString(row)); } }
Example #27
Source File: VipDBTestString.java From singleton with Eclipse Public License 2.0 | 5 votes |
@Test public void test001AddString() throws JsonParseException, JsonMappingException, IOException { logger.info("----------------------test Add String-----------------------------------------"); BufferedReader br = new BufferedReader(new InputStreamReader(jsonInputStream)); String line = null; StringBuilder sb = new StringBuilder(); while ((line = br.readLine()) != null) { sb.append(line); } ResultI18Message i18msg = objectMapper.readValue(sb.toString(), ResultI18Message.class); Map<String, String> multiValueMap = new HashMap<>(); multiValueMap.put("productName", i18msg.getProduct()); multiValueMap.put("version", i18msg.getVersion()); multiValueMap.put("component", i18msg.getComponent()); multiValueMap.put("locale", i18msg.getLocale()); HttpHeaders requestHeaders = new HttpHeaders(); MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8"); requestHeaders.setContentType(type); // body String requestBody = "{\r\n" + " \"vipteststr.email\": \"this is a test\",\r\n" + " \"abcd\":\"this is abcd\"\r\n" + "}"; HttpEntity<String> requestEntity = new HttpEntity<String>(requestBody, requestHeaders); String addStrUrl = baseUrl+"/string/{productName}/{version}/{component}/{locale}/"; ResponseEntity<String> result = testRestTemplate.exchange(addStrUrl, HttpMethod.PUT, requestEntity, String.class, multiValueMap); logger.info(result.getBody()); DbResponseStatus resultStatus = objectMapper.readValue(result.getBody(), DbResponseStatus.class); Assert.assertTrue(resultStatus.getCode() == 0); }
Example #28
Source File: JsonReader.java From dropbox-sdk-java with MIT License | 5 votes |
public static boolean readBoolean(JsonParser parser) throws IOException, JsonReadException { try { boolean b = parser.getBooleanValue(); parser.nextToken(); return b; } catch (JsonParseException ex) { throw JsonReadException.fromJackson(ex); } }
Example #29
Source File: NpmPublishParserTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void throwExceptionOnInvalidUtf8Content() throws Exception { exception.expectMessage("Invalid UTF-8"); exception.expect(JsonParseException.class); try (InputStream in = new ByteArrayInputStream("{\"name\":\"foo\",\"author\":\"bé\"}".getBytes(ISO_8859_1))) { try (JsonParser jsonParser = jsonFactory.createParser(in)) { NpmPublishParser underTest = new NpmPublishParser(jsonParser, storageFacet, HASH_ALGORITHMS); underTest.parse(NO_USER); fail(); // exception should be thrown on parse } } }
Example #30
Source File: Bootloader.java From crazyflie-android-client with GNU General Public License v2.0 | 5 votes |
public static Manifest readManifest (File file) throws IOException { String errorMessage = ""; try { return mMapper.readValue(file, Manifest.class); } catch (JsonParseException jpe) { errorMessage = jpe.getMessage(); } catch (JsonMappingException jme) { errorMessage = jme.getMessage(); } LoggerFactory.getLogger("Bootloader").error("Error while parsing manifest " + file.getName() + ": " + errorMessage); return null; }