@Override public <T> T treeToValue(TreeNode n, Class<T> valueType) throws JsonProcessingException { try { return readValue(treeAsTokens(n), valueType); } catch (JsonProcessingException e) { throw e; } catch (IOException e) { // should not occur, no real i/o... throw JsonMappingException.fromUnexpectedIOE(e); } }
@Override public <T> T as(Class<T> tClazz) throws JWTDecodeException { try { return objectReader.treeAsTokens(data).readValueAs(tClazz); } catch (IOException e) { throw new JWTDecodeException("Couldn't map the Claim value to " + tClazz.getSimpleName(), e); } }
@Override public Map<String, Object> asMap() throws JWTDecodeException { if (!data.isObject()) { return null; } try { TypeReference<Map<String, Object>> mapType = new TypeReference<Map<String, Object>>() { }; JsonParser thisParser = objectReader.treeAsTokens(data); return thisParser.readValueAs(mapType); } catch (IOException e) { throw new JWTDecodeException("Couldn't map the Claim value to Map", e); } }
/** * Convenience method for converting results from given JSON tree into given * value type. Basically short-cut for: *<pre> * objectReader.readValue(src.traverse()) *</pre> */ @SuppressWarnings({ "unchecked", "resource" }) public <T> T readValue(JsonNode src) throws IOException { if (_dataFormatReaders != null) { _reportUndetectableSource(src); } return (T) _bindAndClose(_considerFilter(treeAsTokens(src), false)); }
@Test public void shouldThrowIfAnExtraordinaryExceptionHappensWhenParsingAsGenericMap() throws Exception { JsonNode value = mock(ObjectNode.class); when(value.getNodeType()).thenReturn(JsonNodeType.OBJECT); ObjectReader mockedMapper = mock(ObjectReader.class); JsonNodeClaim claim = (JsonNodeClaim) JsonNodeClaim.claimFromNode(value, mockedMapper); JsonNodeClaim spiedClaim = spy(claim); JsonParser mockedParser = mock(JsonParser.class); when(mockedMapper.treeAsTokens(value)).thenReturn(mockedParser); when(mockedParser.readValueAs(ArgumentMatchers.any(TypeReference.class))).thenThrow(IOException.class); exception.expect(JWTDecodeException.class); spiedClaim.asMap(); }
@Override public <T> T treeToValue(TreeNode n, Class<T> valueType) throws JsonProcessingException { try { return readValue(treeAsTokens(n), valueType); } catch (JsonProcessingException e) { throw e; } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } }
@Override public <T> T treeToValue(TreeNode n, Class<T> valueType) throws JsonProcessingException { try { return readValue(treeAsTokens(n), valueType); } catch (JsonProcessingException e) { throw e; } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } }
@Override public <T> T treeToValue(TreeNode n, Class<T> valueType) throws JsonProcessingException { try { return readValue(treeAsTokens(n), valueType); } catch (JsonProcessingException e) { throw e; } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } }
@Override public <T> T treeToValue(TreeNode n, Class<T> valueType) throws JsonProcessingException { try { return readValue(treeAsTokens(n), valueType); } catch (JsonProcessingException e) { throw e; } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } }
@Override public <T> T treeToValue(TreeNode n, Class<T> valueType) throws JsonProcessingException { try { return readValue(treeAsTokens(n), valueType); } catch (JsonProcessingException e) { throw e; } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } }
@Override public <T> T as(Class<T> tClazz) throws JWTDecodeException { try { return objectReader.treeAsTokens(data).readValueAs(tClazz); } catch (IOException e) { throw new JWTDecodeException("Couldn't map the Claim value to " + tClazz.getSimpleName(), e); } }
@Override public <T> T treeToValue(TreeNode n, Class<T> valueType) throws JsonProcessingException { try { return readValue(treeAsTokens(n), valueType); } catch (JsonProcessingException e) { throw e; } catch (IOException e) { // should not occur, no real i/o... throw JsonMappingException.fromUnexpectedIOE(e); } }
/** * Convenience method for converting results from given JSON tree into given * value type. Basically short-cut for: *<pre> * objectReader.readValue(src.traverse()) *</pre> */ @SuppressWarnings("unchecked") public <T> T readValue(JsonNode src) throws IOException, JsonProcessingException { return (T) _bindAndClose(treeAsTokens(src)); }
@Override public Map<String, Object> asMap() throws JWTDecodeException { if (!data.isObject()) { return null; } try { TypeReference<Map<String, Object>> mapType = new TypeReference<Map<String, Object>>() { }; JsonParser thisParser = objectReader.treeAsTokens(data); return thisParser.readValueAs(mapType); } catch (IOException e) { throw new JWTDecodeException("Couldn't map the Claim value to Map", e); } }
/** * Convenience method for converting results from given JSON tree into given * value type. Basically short-cut for: *<pre> * objectReader.readValue(src.traverse()) *</pre> */ @SuppressWarnings("unchecked") public <T> T readValue(JsonNode src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { _reportUndetectableSource(src); } return (T) _bindAndClose(treeAsTokens(src), _valueToUpdate); }
/** * Convenience method for converting results from given JSON tree into given * value type. Basically short-cut for: *<pre> * objectReader.readValue(src.traverse()) *</pre> */ @SuppressWarnings("unchecked") public <T> T readValue(JsonNode src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { _reportUndetectableSource(src); } return (T) _bindAndClose(treeAsTokens(src), _valueToUpdate); }
/** * Convenience method for converting results from given JSON tree into given * value type. Basically short-cut for: *<pre> * objectReader.readValue(src.traverse()) *</pre> */ @SuppressWarnings("unchecked") public <T> T readValue(JsonNode src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { _reportUndetectableSource(src); } return (T) _bindAndClose(treeAsTokens(src), _valueToUpdate); }
/** * Convenience method for converting results from given JSON tree into given * value type. Basically short-cut for: *<pre> * objectReader.readValue(src.traverse()) *</pre> */ @SuppressWarnings("unchecked") public <T> T readValue(JsonNode src) throws IOException, JsonProcessingException { if (_dataFormatReaders != null) { _reportUndetectableSource(src); } return (T) _bindAndClose(_considerFilter(treeAsTokens(src), false)); }
/** * Convenience method for converting results from given JSON tree into given * value type. Basically short-cut for: *<pre> * objectReader.readValue(src.traverse()) *</pre> */ @SuppressWarnings({ "unchecked", "resource" }) public <T> T readValue(JsonNode src) throws IOException { if (_dataFormatReaders != null) { _reportUndetectableSource(src); } return (T) _bindAndClose(_considerFilter(treeAsTokens(src), false)); }