Package io.github.astrapi69.gson
Class ObjectToJsonExtensions
- java.lang.Object
-
- io.github.astrapi69.gson.ObjectToJsonExtensions
-
public final class ObjectToJsonExtensions extends java.lang.ObjectThe classObjectToJsonExtensionsconverts java objects to json string objects.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> java.lang.StringtoJson(java.util.List<T> list)Creates from the givenLista json stringstatic <T> java.lang.StringtoJson(java.util.List<T> list, com.google.gson.Gson gson)Creates from the givenLista json stringstatic <T> java.lang.StringtoJson(T object)Creates a jsonStringfrom the given argument objectstatic <T> java.lang.StringtoJson(T object, com.google.gson.Gson gson)Creates a jsonStringfrom the given argument object
-
-
-
Method Detail
-
toJson
public static <T> java.lang.String toJson(java.util.List<T> list)
Creates from the givenLista json string- Type Parameters:
T- the generic type- Parameters:
list- the list to transform- Returns:
- the json string
-
toJson
public static <T> java.lang.String toJson(java.util.List<T> list, com.google.gson.Gson gson)Creates from the givenLista json string- Type Parameters:
T- the generic type- Parameters:
list- the list to transformgson- the gson object- Returns:
- the json string
-
toJson
public static <T> java.lang.String toJson(T object)
Creates a jsonStringfrom the given argument object- Type Parameters:
T- the generic type of the given argument object- Parameters:
object- the object to transform- Returns:
- the json string
-
toJson
public static <T> java.lang.String toJson(T object, com.google.gson.Gson gson)Creates a jsonStringfrom the given argument object- Type Parameters:
T- the generic type of the given argument object- Parameters:
object- the object to transformgson- the gson object- Returns:
- the json string
-
-