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- Since:
2022-11-05
trydofor
-
-
Constructor Summary
Constructors Constructor Description JacksonHelper()
-
Method Summary
Modifier and Type Method Description static voidinitGlobal(ObjectMapper jsonMapper, XmlMapper xmlMapper)Init the ObjectMapper for Wings configuration static ObjectMapperJsonWings()static XmlMapperXmlWings()static ObjectMapperwings(boolean json)static <T> Tobject(@Nullable() String text, @NotNull() Class<T> targetType)Auto read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(@Nullable() String text, @NotNull() JavaType targetType)Auto read text to object, if text asXml, read as xml, otherwise as json static <T> Tobject(@Nullable() String text, @NotNull() TypeReference<T> targetType)Auto read text to object, if text asXml, read as xml, otherwise as json static JsonNodeobject(@Nullable() String text)Auto read text to object, if text asXml, read as xml, otherwise as json static booleanasXml(@Nullable() String str)whether `str` has xml characteristics, i.e. static Stringstring(@Nullable() Object obj)Serialization (json) using the wings convention, output as string wherever possible to ensure data precision static Stringstring(@Nullable() Object obj, boolean json)Serialization (json or xml) using the wings convention, output as string wherever possible to ensure data precision 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
-
initGlobal
static void initGlobal(ObjectMapper jsonMapper, XmlMapper xmlMapper)
Init the ObjectMapper for Wings configuration
- Parameters:
jsonMapper- handle jsonxmlMapper- handle xml
-
JsonWings
@NotNull() static ObjectMapper JsonWings()
-
XmlWings
@NotNull() static XmlMapper XmlWings()
-
wings
@NotNull() static ObjectMapper wings(boolean json)
-
object
@Contract(value = "!null,_->!null") static <T> T object(@Nullable() String text, @NotNull() Class<T> targetType)
Auto read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "!null,_->!null") static <T> T object(@Nullable() 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(@Nullable() String text, @NotNull() TypeReference<T> targetType)
Auto read text to object, if text asXml, read as xml, otherwise as json
-
object
@Contract(value = "!null->!null") static JsonNode object(@Nullable() String text)
Auto read text to object, if text asXml, read as xml, otherwise as json
-
asXml
static boolean asXml(@Nullable() String str)
whether `str` has xml characteristics, i.e. the first and last characters are angle brackets or not
-
string
@Contract(value = "!null->!null") static String string(@Nullable() Object obj)
Serialization (json) using the wings convention, output as string wherever possible to ensure data precision
-
string
@Contract(value = "!null,_->!null") static String string(@Nullable() Object obj, boolean json)
Serialization (json or xml) using the wings convention, output as string wherever possible to ensure data precision
-
getString
@Contract(value = "_,_,!null->!null") static String getString(JsonNode node, String field, String defaults)
-
getBoolean
static boolean getBoolean(JsonNode node, String field, boolean defaults)
-
-
-
-