| Modifier and Type | Method and Description |
|---|---|
static com.fasterxml.jackson.databind.ObjectMapper |
objectMapper()
Returns the
object mapper used by this class. |
static com.fasterxml.jackson.databind.ObjectWriter |
objectWriter()
Returns The single object writer instantiated by this class.
|
static <T> T |
readValue(File file,
Class<T> type)
Read a JSON value of the given type from a file.
|
static <T> T |
readValue(InputStream stream,
Class<T> type)
Read a JSON value of the given type from a stream.
|
static <T> T |
readValue(String string,
Class<T> type)
Read a JSON value of the given type from a string.
|
static String |
toJson(Object value)
Converts the given value to JSON.
|
static String |
toString(Object value)
Converts the given value to a string of the form <simple-class-name>("<
json-string>)").
|
public static com.fasterxml.jackson.databind.ObjectMapper objectMapper()
object mapper used by this class.object mapper used by this class.@NonNull public static com.fasterxml.jackson.databind.ObjectWriter objectWriter()
This method may be used for specialized serialization tasks. It is less expensive than instantiating one of your own and ensures that values are serialized consistently.
public static <T> T readValue(@NonNull
File file,
@NonNull
Class<T> type)
throws IOException
T - The type of value to read.file - The file from which to read the JSON value.type - A class modeling the value type to read.IOException - if a low-level I/O problem (unexpected end-of-input, network error) occurs.public static <T> T readValue(@NonNull
InputStream stream,
@NonNull
Class<T> type)
throws IOException
T - The type of value to read.stream - The stream from which to read the JSON value.type - A class modeling the value type to read.IOException - if a low-level I/O problem (unexpected end-of-input, network error) occurs.public static <T> T readValue(@NonNull
String string,
@NonNull
Class<T> type)
throws IOException
T - The type of value to read.string - The string from which to read the JSON value.type - A class modeling the value type to read.IOException - if a low-level I/O problem (unexpected end-of-input, network error) occurs.@NonNull public static String toJson(@Nullable Object value)
value - The value to convert.value.@NonNull public static String toString(@Nullable Object value)
This method is frequently used toString implementations.
value - The value to convert.Copyright © 2021. All rights reserved.