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 -
Method Summary
Modifier and TypeMethodDescriptioncom.google.gson.JsonElementParse the supplied JSONcontentstring using gson.com.google.gson.JsonElementparseResource(String resource) Parse the supplied JSONresouceusing gson.Methods inherited from class org.apache.velocity.tools.generic.SafeConfig
configure, configure, getLog, initLogger, isConfigLocked, isSafeMode, setLockConfig, setSafeMode
-
Constructor Details
-
GsonTool
public GsonTool()Construct aGsonToolobject.
-
-
Method Details
-
parse
Parse the supplied JSONcontentstring using gson.- Parameters:
content- JSON content string- Returns:
- An
JsonElementthat wraps the suppliedcontent.
-
parseResource
Parse the supplied JSONresouceusing gson.- Parameters:
resource- the resource name- Returns:
- An
JsonElementthat wraps the JSON inresource.
-