java.lang.Object
technology.sola.json.SolaJson
SolaJson contains methods for parsing strings into
JsonElements and serializing JsonElements 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> Tparse(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 aListof type T using aJsonMapper.<T> Stringstringify(List<T> list, JsonMapper<T> jsonMapper) Serializes a list of type T objects to a string using aJsonMapper.Serializes aJsonArray.stringify(JsonObject jsonObject) Serializes aJsonObject.<T> Stringstringify(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- theJsonMapperto use during conversion- Returns:
- the converted Java object of type T
-
parseList
Parses a JSON string into aListof type T using aJsonMapper.- Type Parameters:
T- the type of the object to convert to- Parameters:
jsonString- the JSON string to parsejsonMapper- theJsonMapperto use during conversion- Returns:
- the converted List of type T
-
stringify
Serializes aJsonObject.- Parameters:
jsonObject- theJsonObjectto serialize- Returns:
- serialized JSON string
-
stringify
Serializes aJsonArray.- Parameters:
jsonArray- theJsonArrayto 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- theJsonMapperto use during conversion- Returns:
- serialized JSON string
-
stringify
Serializes a list of type T objects to a string using aJsonMapper.- Type Parameters:
T- the type of the object to serialize- Parameters:
list- the list of objects to serializejsonMapper- theJsonMapperto use during conversion- Returns:
- serialized JSON string
-