public class ObjectToJsonExtensions
extends java.lang.Object
ObjectToJsonExtensions converts java objects to json string objects.| Constructor and Description |
|---|
ObjectToJsonExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static <T> java.lang.String |
toJson(@NonNull java.util.List<T> list)
Creates from the given
List a json string |
static <T> java.lang.String |
toJson(@NonNull java.util.List<T> list,
@NonNull com.fasterxml.jackson.databind.ObjectMapper mapper)
Creates from the given
List a json string |
static <T> java.lang.String |
toJson(T object)
Creates a json
String from the given argument object |
static <T> java.lang.String |
toJson(T object,
boolean newMapper)
Creates a json
String from the given Object |
static <T> java.lang.String |
toJson(T object,
@NonNull com.fasterxml.jackson.databind.ObjectMapper mapper)
Creates a json
String from the given Object and the given object mapper |
public static <T> java.lang.String toJson(@NonNull
@NonNull java.util.List<T> list)
throws com.fasterxml.jackson.core.JsonGenerationException,
com.fasterxml.jackson.databind.JsonMappingException,
java.io.IOException
List a json stringT - the generic typelist - the listcom.fasterxml.jackson.core.JsonGenerationException - If an error occurs by writing json stringcom.fasterxml.jackson.databind.JsonMappingException - the If an error occurs when mapping the string into Objectjava.io.IOException - Signals that an I/O exception has occurred.public static <T> java.lang.String toJson(@NonNull
@NonNull java.util.List<T> list,
@NonNull
@NonNull com.fasterxml.jackson.databind.ObjectMapper mapper)
throws java.io.IOException,
com.fasterxml.jackson.core.JsonGenerationException,
com.fasterxml.jackson.databind.JsonMappingException
List a json stringT - the generic typelist - the listmapper - the object mapperjava.io.IOException - Signals that an I/O exception has occurredcom.fasterxml.jackson.core.JsonGenerationException - the json generation exceptioncom.fasterxml.jackson.databind.JsonMappingException - the json mapping exceptionpublic static <T> java.lang.String toJson(@NonNull
T object)
throws com.fasterxml.jackson.core.JsonProcessingException
String from the given argument objectT - the generic type of the given argument objectobject - the object.com.fasterxml.jackson.core.JsonProcessingException - If an error occurs when converting object to Stringpublic static <T> java.lang.String toJson(@NonNull
T object,
boolean newMapper)
throws com.fasterxml.jackson.core.JsonProcessingException
String from the given ObjectT - the generic typeobject - the objectnewMapper - flag that indicates if a new ObjectMapper should be created. if true a new
ObjectMapper will be created otherwise the ObjectMapper from this class will be
returned.com.fasterxml.jackson.core.JsonProcessingException - If an error occurs when converting object to Stringpublic static <T> java.lang.String toJson(@NonNull
T object,
@NonNull
@NonNull com.fasterxml.jackson.databind.ObjectMapper mapper)
throws com.fasterxml.jackson.core.JsonProcessingException
String from the given Object and the given object mapperT - the generic typeobject - the objectmapper - the object mappercom.fasterxml.jackson.core.JsonProcessingException - the json processing exception