Class JacksonHelper
-
- All Implemented Interfaces:
public class JacksonHelperXML limitation The common uses are: (1) single element node, XML can not distinguish between a single value or only one value in the array, unless nested wrap. (2) Xml can not recognize the data type, while Json has string, number, boolean, object, array Jackson Plain - `transient` output - `@Transient` No output - `byte[]` as base64, `[]` as `""` - `char[]` as String, `[]` as `""` - WRITE_DATES_AS_TIMESTAMPS = false - `ZonedDateTime` parse as `2023-04-04T21:07:08Z` lost timezone - `OffsetDateTime` parse as `2023-04-05T10:07:08Z` lost timezone Jackson Wings - `transient` No output - WRITE_DATES_AS_TIMESTAMPS = false - `LocalDateTime` as `"2023-04-05T06:07:08"` - `ZonedDateTime` as `"2023-04-05T06:07:08[America/New_York]"` keep timezone - `OffsetDateTime` as `"2023-04-05T06:07:08-04:00"` keep timezone Jackson Bean - `LocalDateTime` as `"2023-04-05 06:07:08"` - `ZonedDateTime` as `"2023-04-05 06:07:08 Asia/Shanghai"` - `OffsetDateTime` as `"2023-04-05 06:07:08 +08:00"` - `float`,`double` as `"3.14159"` - `BigDecimal`,`BigInteger` as `"299792458"`- Since:
2022-11-05
trydofor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumJacksonHelper.Style
-
Field Summary
Fields Modifier and Type Field Description public final static Array<DeserializationFeature>EnableDeserializationFeaturepublic final static Array<JsonGenerator.Feature>EnableJsonGeneratorFeaturepublic final static Array<MapperFeature>EnableMapperFeaturepublic final static Array<JsonParser.Feature>EnableParserFeaturepublic final static Array<SerializationFeature>EnableSerializationFeaturepublic final static Array<JsonParser.Feature>DisableParserFeaturepublic final static Array<DeserializationFeature>DisableDeserializationFeaturepublic final static Array<SerializationFeature>DisableSerializationFeaturepublic final static JacksonLocalDateTimeDeserializerPlainLocalDateTimeDeserializerpublic final static JacksonOffsetDateTimeDeserializerPlainOffsetDateTimeDeserializerpublic final static JacksonZonedDateTimeSerializerPlainZonedDateTimeSerializerpublic final static JacksonZonedDateTimeDeserializerPlainZonedDateTimeDeserializerpublic final static SimpleModulePlainDateTimeModulepublic final static ObjectMapperJsonPlainpublic final static XmlMapperXmlPlainpublic final static TypeFactoryTypeFactoryPlain
-
Constructor Summary
Constructors Constructor Description JacksonHelper()
-
Method Summary
Modifier and Type Method Description static <T extends MapperBuilder<out Object, out Object>> TbuildPlain(@NotNull() T builder)static <T extends ObjectMapper> TbuildWings(@NotNull() T mapper)static booleanisPrepared(@NotNull() JacksonHelper.Style style)static ObjectMapperJsonBean()spring bean style Mapper at web tier with ' ' datetime and auto timezone/i18n convert static XmlMapperXmlBean()spring bean style Mapper at web tier with ' ' datetime and auto timezone/i18n convert static ObjectMapperMapperBean(boolean json)spring bean style Mapper at web tier with ' ' datetime and auto timezone/i18n convert static ObjectMapperJsonPlain()fastjon default with WRITE_DATES_AS_TIMESTAMPS=false and other Disable/Enable static XmlMapperXmlPlain()fastjon default with WRITE_DATES_AS_TIMESTAMPS=false and other Disable/Enable static ObjectMapperMapperPlain(boolean json)fastjon default with WRITE_DATES_AS_TIMESTAMPS=false and other Disable/Enable static ObjectMapperJsonWings()wings config with 'T' datetime format without timezone/i18n conversion static XmlMapperXmlWings()wings config with 'T' datetime format without timezone/i18n conversion static ObjectMapperMapperWings(boolean json)wings config with 'T' datetime format without timezone/i18n conversion static ObjectMapperMapper(@NotNull() JacksonHelper.Style style, boolean json)wings configed Mapper without auto timezone convert static booleanasXml(String str)whether `str` has xml characteristics, i.e. static booleanasXml(Array<byte> str)whether `str` has xml characteristics, i.e. static JavaTypejavaType(@NotNull() Class<out Object> targetType, Array<Class<out Object>> generics)construct jackson's JavaType by TypeSugar static JavaTypejavaType(@NotNull() TypeDescriptor targetType)construct jackson's JavaType in spring way static JavaTypejavaType(@NotNull() ResolvableType targetType)construct jackson's JavaType in spring way static <T> Tobject(String text, @NotNull() Class<out Object> targetType, Array<Class<out Object>> generics)wings style read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(@NotNull() JacksonHelper.Style style, String text, @NotNull() Class<out Object> targetType, Array<Class<out Object>> generics)Auto read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(String text, @NotNull() JavaType targetType)wings style read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(@NotNull() JacksonHelper.Style style, String text, @NotNull() JavaType targetType)Auto read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(String text, @NotNull() ResolvableType targetType)wings style read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(@NotNull() JacksonHelper.Style style, String text, @NotNull() ResolvableType targetType)Auto read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(String text, @NotNull() TypeDescriptor targetType)wings style read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(@NotNull() JacksonHelper.Style style, String text, @NotNull() TypeDescriptor targetType)Auto read text to object, if text asXml, read as xml, otherwise as json static JsonNodeobject(String text)wings style read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(Array<byte> text, @NotNull() Class<out Object> targetType, Array<Class<out Object>> generics)wings style read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(@NotNull() JacksonHelper.Style style, Array<byte> text, @NotNull() Class<out Object> targetType, Array<Class<out Object>> generics)Auto read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(Array<byte> text, @NotNull() JavaType targetType)wings style read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(@NotNull() JacksonHelper.Style style, Array<byte> text, @NotNull() JavaType targetType)Auto read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(Array<byte> text, @NotNull() ResolvableType targetType)wings style read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(@NotNull() JacksonHelper.Style style, Array<byte> text, @NotNull() ResolvableType targetType)Auto read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(Array<byte> text, @NotNull() TypeDescriptor targetType)wings style read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(@NotNull() JacksonHelper.Style style, Array<byte> text, @NotNull() TypeDescriptor targetType)Auto read text to object, if text asXml, read as xml, otherwise as json static JsonNodeobject(Array<byte> text)wings style read text to object, if text asXml, read as xml, otherwise as json static JsonNodeobject(@NotNull() JacksonHelper.Style style, Array<byte> text)Auto read text to object, if text asXml, read as xml, otherwise as json static Stringstring(Object obj)wings style serialization to json static Stringstring(@NotNull() JacksonHelper.Style style, Object obj)serialization to json static Stringstring(Object obj, boolean json)wings style serialization to json/xml static Stringstring(@NotNull() JacksonHelper.Style style, Object obj, boolean json)serialization to json/xml static Array<byte>bytes(Object obj)wings style serialization to json static Array<byte>bytes(@NotNull() JacksonHelper.Style style, Object obj)serialization to json static Array<byte>bytes(Object obj, boolean json)wings style serialization to json/xml static Array<byte>bytes(@NotNull() JacksonHelper.Style style, Object obj, boolean json)serialization to json/xml static StringgetString(JsonNode node, String field, String defaults)static booleangetBoolean(JsonNode node, String field, boolean defaults)static intgetInt(JsonNode node, String field, int defaults)static longgetLong(JsonNode node, String field, long defaults)static doublegetDouble(JsonNode node, String field, double defaults)-
-
Method Detail
-
buildPlain
@Contract(value = "_->param1") static <T extends MapperBuilder<out Object, out Object>> T buildPlain(@NotNull() T builder)
-
buildWings
@Contract(value = "_->param1") static <T extends ObjectMapper> T buildWings(@NotNull() T mapper)
-
isPrepared
static boolean isPrepared(@NotNull() JacksonHelper.Style style)
-
JsonBean
@NotNull() static ObjectMapper JsonBean()
spring bean style Mapper at web tier with ' ' datetime and auto timezone/i18n convert
-
XmlBean
@NotNull() static XmlMapper XmlBean()
spring bean style Mapper at web tier with ' ' datetime and auto timezone/i18n convert
-
MapperBean
@NotNull() static ObjectMapper MapperBean(boolean json)
spring bean style Mapper at web tier with ' ' datetime and auto timezone/i18n convert
-
JsonPlain
@NotNull() static ObjectMapper JsonPlain()
fastjon default with WRITE_DATES_AS_TIMESTAMPS=false and other Disable/Enable
-
XmlPlain
@NotNull() static XmlMapper XmlPlain()
fastjon default with WRITE_DATES_AS_TIMESTAMPS=false and other Disable/Enable
-
MapperPlain
@NotNull() static ObjectMapper MapperPlain(boolean json)
fastjon default with WRITE_DATES_AS_TIMESTAMPS=false and other Disable/Enable
-
JsonWings
@NotNull() static ObjectMapper JsonWings()
wings config with 'T' datetime format without timezone/i18n conversion
-
XmlWings
@NotNull() static XmlMapper XmlWings()
wings config with 'T' datetime format without timezone/i18n conversion
-
MapperWings
@NotNull() static ObjectMapper MapperWings(boolean json)
wings config with 'T' datetime format without timezone/i18n conversion
-
Mapper
@NotNull() static ObjectMapper Mapper(@NotNull() JacksonHelper.Style style, boolean json)
wings configed Mapper without auto timezone convert
-
asXml
@Contract(value = "null->false") static boolean asXml(String str)
whether `str` has xml characteristics, i.e. the first and last characters are angle brackets or not
-
asXml
@Contract(value = "null->false") static boolean asXml(Array<byte> str)
whether `str` has xml characteristics, i.e. the first and last characters are angle brackets or not
-
javaType
static JavaType javaType(@NotNull() Class<out Object> targetType, Array<Class<out Object>> generics)
construct jackson's JavaType by TypeSugar
-
javaType
static JavaType javaType(@NotNull() TypeDescriptor targetType)
construct jackson's JavaType in spring way
-
javaType
static JavaType javaType(@NotNull() ResolvableType targetType)
construct jackson's JavaType in spring way
-
object
@Contract(value = "!null,_,_->!null") static <T> T object(String text, @NotNull() Class<out Object> targetType, Array<Class<out Object>> generics)
wings style read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "_,!null,_,_ -> !null") static <T> T object(@NotNull() JacksonHelper.Style style, String text, @NotNull() Class<out Object> targetType, Array<Class<out Object>> generics)
Auto read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "!null,_->!null") static <T> T object(String text, @NotNull() JavaType targetType)
wings style read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "_,!null,_ -> !null") static <T> T object(@NotNull() JacksonHelper.Style style, String text, @NotNull() JavaType targetType)
Auto read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "!null,_->!null") static <T> T object(String text, @NotNull() ResolvableType targetType)
wings style read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "_,!null,_ -> !null") static <T> T object(@NotNull() JacksonHelper.Style style, String text, @NotNull() ResolvableType targetType)
Auto read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "!null,_->!null") static <T> T object(String text, @NotNull() TypeDescriptor targetType)
wings style read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "_,!null,_ -> !null") static <T> T object(@NotNull() JacksonHelper.Style style, String text, @NotNull() TypeDescriptor targetType)
Auto read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "!null->!null") static JsonNode object(String text)
wings style read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "!null,_,_->!null") static <T> T object(Array<byte> text, @NotNull() Class<out Object> targetType, Array<Class<out Object>> generics)
wings style read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "_,!null,_,_ -> !null") static <T> T object(@NotNull() JacksonHelper.Style style, Array<byte> text, @NotNull() Class<out Object> targetType, Array<Class<out Object>> generics)
Auto read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "!null,_->!null") static <T> T object(Array<byte> text, @NotNull() JavaType targetType)
wings style read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "_, !null, _ -> !null") static <T> T object(@NotNull() JacksonHelper.Style style, Array<byte> text, @NotNull() JavaType targetType)
Auto read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "!null,_->!null") static <T> T object(Array<byte> text, @NotNull() ResolvableType targetType)
wings style read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "_, !null, _ -> !null") static <T> T object(@NotNull() JacksonHelper.Style style, Array<byte> text, @NotNull() ResolvableType targetType)
Auto read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "!null,_->!null") static <T> T object(Array<byte> text, @NotNull() TypeDescriptor targetType)
wings style read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "_, !null, _ -> !null") static <T> T object(@NotNull() JacksonHelper.Style style, Array<byte> text, @NotNull() TypeDescriptor targetType)
Auto read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "!null->!null") static JsonNode object(Array<byte> text)
wings style read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "_, !null -> !null") static JsonNode object(@NotNull() JacksonHelper.Style style, Array<byte> text)
Auto read text to object, if text asXml, read as xml, otherwise as json
-
string
@Contract(value = "!null->!null") static String string(Object obj)
wings style serialization to json
-
string
@Contract(value = "_, !null -> !null") static String string(@NotNull() JacksonHelper.Style style, Object obj)
serialization to json
-
string
@Contract(value = "!null,_->!null") static String string(Object obj, boolean json)
wings style serialization to json/xml
-
string
@Contract(value = "_, !null, _ -> !null") static String string(@NotNull() JacksonHelper.Style style, Object obj, boolean json)
serialization to json/xml
-
bytes
@Contract(value = "!null->!null") static Array<byte> bytes(Object obj)
wings style serialization to json
-
bytes
@Contract(value = "_, !null -> !null") static Array<byte> bytes(@NotNull() JacksonHelper.Style style, Object obj)
serialization to json
-
bytes
@Contract(value = "!null,_->!null") static Array<byte> bytes(Object obj, boolean json)
wings style serialization to json/xml
-
bytes
@Contract(value = "_, !null, _ -> !null") static Array<byte> bytes(@NotNull() JacksonHelper.Style style, Object obj, boolean json)
serialization to json/xml
-
getString
@Contract(value = "_,_,!null->!null") static String getString(JsonNode node, String field, String defaults)
-
getBoolean
static boolean getBoolean(JsonNode node, String field, boolean defaults)
-
-
-
-