Class GsonTool

java.lang.Object
org.apache.velocity.tools.generic.SafeConfig
io.github.cs1302uga.GsonTool

@DefaultKey("gson") public class GsonTool extends org.apache.velocity.tools.generic.SafeConfig
An Apache Velocity tool that provides utility methods to manipulate JSON code using the gson JSON library.
Author:
Michael E. Cotterell
  • Field Summary

    Fields inherited from class org.apache.velocity.tools.generic.SafeConfig

    LOCK_CONFIG_KEY, log, LOGGER_NAME_KEY, SAFE_MODE_KEY, USE_CLASS_LOGGER_KEY
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a GsonTool object.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.google.gson.JsonElement
    parse(String content)
    Parse the supplied JSON content string using gson.
    com.google.gson.JsonElement
    Parse the supplied JSON resouce using gson.

    Methods inherited from class org.apache.velocity.tools.generic.SafeConfig

    configure, configure, getLog, initLogger, isConfigLocked, isSafeMode, setLockConfig, setSafeMode

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GsonTool

      public GsonTool()
      Construct a GsonTool object.
  • Method Details

    • parse

      public com.google.gson.JsonElement parse(String content)
      Parse the supplied JSON content string using gson.
      Parameters:
      content - JSON content string
      Returns:
      An JsonElement that wraps the supplied content.
    • parseResource

      public com.google.gson.JsonElement parseResource(String resource)
      Parse the supplied JSON resouce using gson.
      Parameters:
      resource - the resource name
      Returns:
      An JsonElement that wraps the JSON in resource.