public class JacksonUtil extends Object
JsonNode in a
JsonDeserializer, you can simply use the following code:
jp.getCodec().readTree(jp)
| Constructor and Description |
|---|
JacksonUtil() |
| Modifier and Type | Method and Description |
|---|---|
private static <V> V |
readAtomicValue(com.fasterxml.jackson.databind.JsonNode node,
Class<V> type) |
static <V> V |
readValue(com.fasterxml.jackson.databind.JsonNode node,
Class<V> type) |
static <V> V |
readValue(com.fasterxml.jackson.databind.JsonNode node,
Class<V> type,
boolean required) |
static <V> V |
readValue(com.fasterxml.jackson.databind.JsonNode node,
String fieldName,
Class<V> type,
boolean required) |
private static void |
writeNumber(com.fasterxml.jackson.core.JsonGenerator jgen,
Number value) |
static void |
writeValue(com.fasterxml.jackson.core.JsonGenerator jgen,
Object value) |
public static void writeValue(com.fasterxml.jackson.core.JsonGenerator jgen,
Object value)
throws IOException
jgen - the JsonGenerator.value - the value to write depending on its type.IOException - in case of an I/O error.private static void writeNumber(com.fasterxml.jackson.core.JsonGenerator jgen,
Number value)
throws IOException
IOExceptionpublic static <V> V readValue(com.fasterxml.jackson.databind.JsonNode node,
String fieldName,
Class<V> type,
boolean required)
V - the generic type of the value to read.node - the JsonNode to parse.fieldName - the name of the JSON property to read from the JsonNode.type - the Class reflecting the type of the requested value.required - - true if the value is required and an exception shall be thrown if missing, false
otherwise (make it optional and return null if not present).null if required is false.RuntimeException - in case of an error.public static <V> V readValue(com.fasterxml.jackson.databind.JsonNode node,
Class<V> type,
boolean required)
V - the generic type of the value to read.node - the JsonNode to parse.type - the Class reflecting the type of the requested value.required - - true if the value is required and an exception shall be thrown if missing, false
otherwise (make it optional and return null if not present).null if required is false.RuntimeException - in case of an error.public static <V> V readValue(com.fasterxml.jackson.databind.JsonNode node,
Class<V> type)
V - the generic type of the value to read.node - the JsonNode to parse.type - the Class reflecting the type of the requested value.null if required is false.RuntimeException - in case of an error.private static <V> V readAtomicValue(com.fasterxml.jackson.databind.JsonNode node,
Class<V> type)
Copyright © 2014–2019 devon4j-Team. All rights reserved.