Class SolaJson

java.lang.Object
technology.sola.json.SolaJson

@NullMarked public class SolaJson extends Object
SolaJson contains methods for parsing strings into JsonElements and serializing JsonElements into strings.
  • Constructor Details

  • Method Details

    • parse

      public JsonElement parse(String jsonString)
      Parses a JSON string into a JsonElement.
      Parameters:
      jsonString - the JSON string to parse
      Returns:
      the parsed JsonElement
    • parse

      public <T> T parse(String jsonString, JsonMapper<T> jsonMapper)
      Parses a JSON string into an object of type T using a JsonMapper.
      Type Parameters:
      T - the type of the object to convert to
      Parameters:
      jsonString - the JSON string to parse
      jsonMapper - the JsonMapper to use during conversion
      Returns:
      the converted Java object of type T
    • parseList

      public <T> List<T> parseList(String jsonString, JsonMapper<T> jsonMapper)
      Parses a JSON string into a List of type T using a JsonMapper.
      Type Parameters:
      T - the type of the object to convert to
      Parameters:
      jsonString - the JSON string to parse
      jsonMapper - the JsonMapper to use during conversion
      Returns:
      the converted List of Java object of type T
    • stringify

      public String stringify(JsonObject jsonObject)
      Serializes a JsonObject.
      Parameters:
      jsonObject - the JsonObject to serialize
      Returns:
      serialized JSON string
    • stringify

      public String stringify(JsonArray jsonArray)
      Serializes a JsonArray.
      Parameters:
      jsonArray - the JsonArray to serialize
      Returns:
      serialized JSON string
    • stringify

      public <T> String stringify(T object, JsonMapper<T> jsonMapper)
      Serializes an object of type T to a string using a JsonMapper.
      Type Parameters:
      T - the type of the object to serialize
      Parameters:
      object - the object to serialize
      jsonMapper - the JsonMapper to use during conversion
      Returns:
      serialized JSON string
    • stringify

      public <T> String stringify(List<T> list, JsonMapper<T> jsonMapper)
      Serializes a list of objects of type T to a string using a JsonMapper.
      Type Parameters:
      T - the type of the object to serialize
      Parameters:
      list - the list of objects to serialize
      jsonMapper - the JsonMapper to use during conversion
      Returns:
      serialized JSON string