java.lang.Object
technology.sola.json.SolaJson
SolaJson contains methods for parsing strings into
JsonElement
s and serializing JsonElement
s into strings.-
Constructor Summary
ConstructorsConstructorDescriptionSolaJson()
Creates a new SolaJson instance with defaultJsonSerializerConfig
.SolaJson
(JsonSerializerConfig config) Creates a new SolaJson instance with desiredJsonSerializerConfig
. -
Method Summary
Modifier and TypeMethodDescriptionParses a JSON string into aJsonElement
.<T> T
parse
(String jsonString, JsonMapper<T> jsonMapper) Parses a JSON string into an object of type T using aJsonMapper
.<T> List<T>
parseList
(String jsonString, JsonMapper<T> jsonMapper) Parses a JSON string into aList
of type T using aJsonMapper
.<T> String
stringify
(List<T> list, JsonMapper<T> jsonMapper) Serializes a list of objects of type T to a string using aJsonMapper
.Serializes aJsonArray
.stringify
(JsonObject jsonObject) Serializes aJsonObject
.<T> String
stringify
(T object, JsonMapper<T> jsonMapper) Serializes an object of type T to a string using aJsonMapper
.
-
Constructor Details
-
SolaJson
public SolaJson()Creates a new SolaJson instance with defaultJsonSerializerConfig
. -
SolaJson
Creates a new SolaJson instance with desiredJsonSerializerConfig
.- Parameters:
config
- the serializer configuration
-
-
Method Details
-
parse
Parses a JSON string into aJsonElement
.- Parameters:
jsonString
- the JSON string to parse- Returns:
- the parsed
JsonElement
-
parse
Parses a JSON string into an object of type T using aJsonMapper
.- Type Parameters:
T
- the type of the object to convert to- Parameters:
jsonString
- the JSON string to parsejsonMapper
- theJsonMapper
to use during conversion- Returns:
- the converted Java object of type T
-
parseList
Parses a JSON string into aList
of type T using aJsonMapper
.- Type Parameters:
T
- the type of the object to convert to- Parameters:
jsonString
- the JSON string to parsejsonMapper
- theJsonMapper
to use during conversion- Returns:
- the converted List of Java object of type T
-
stringify
Serializes aJsonObject
.- Parameters:
jsonObject
- theJsonObject
to serialize- Returns:
- serialized JSON string
-
stringify
Serializes aJsonArray
.- Parameters:
jsonArray
- theJsonArray
to serialize- Returns:
- serialized JSON string
-
stringify
Serializes an object of type T to a string using aJsonMapper
.- Type Parameters:
T
- the type of the object to serialize- Parameters:
object
- the object to serializejsonMapper
- theJsonMapper
to use during conversion- Returns:
- serialized JSON string
-
stringify
Serializes a list of objects of type T to a string using aJsonMapper
.- Type Parameters:
T
- the type of the object to serialize- Parameters:
list
- the list of objects to serializejsonMapper
- theJsonMapper
to use during conversion- Returns:
- serialized JSON string
-