Package io.github.astrapi69.gson
Class ObjectToJsonExtensions
- java.lang.Object
-
- io.github.astrapi69.gson.ObjectToJsonExtensions
-
public final class ObjectToJsonExtensions extends java.lang.Object
The classObjectToJsonExtensions
converts java objects to json string objects.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> java.lang.String
toJson(java.util.List<T> list)
Creates from the givenList
a json stringstatic <T> java.lang.String
toJson(java.util.List<T> list, com.google.gson.Gson gson)
Creates from the givenList
a json stringstatic <T> java.lang.String
toJson(T object)
Creates a jsonString
from the given argument objectstatic <T> java.lang.String
toJson(T object, com.google.gson.Gson gson)
Creates a jsonString
from the given argument object
-
-
-
Method Detail
-
toJson
public static <T> java.lang.String toJson(java.util.List<T> list)
Creates from the givenList
a 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 givenList
a 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 jsonString
from 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 jsonString
from 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
-
-