public final class JsonUtils
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
JsonUtils()
Protected constructor for a utility class.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
joinArguments(java.util.List<java.lang.String> commandArgs)
Given an ordered list of command line arguments join them back together as a space delimited String where
each argument is wrapped in '.
|
static java.lang.String |
marshall(java.lang.Object value)
Convert a Java object to a JSON string.
|
static java.util.List<java.lang.String> |
splitArguments(java.lang.String commandArgs)
Given a flat string of command line arguments this method will attempt to tokenize the string and split it for
use in DTOs.
|
static <T extends java.util.Collection> |
unmarshall(java.lang.String source,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
Convert a JSON string of a collection back to a Java object.
|
public static java.lang.String marshall(java.lang.Object value) throws GenieException
value
- The Java object to marshallGenieException
- For any marshalling exceptionpublic static <T extends java.util.Collection> T unmarshall(java.lang.String source, com.fasterxml.jackson.core.type.TypeReference<T> typeReference) throws GenieException
T
- The type of the collection ie Set of Stringsource
- The JSON stringtypeReference
- The type reference of the collection to unmarshall toGenieException
- For any exception during unmarshalling@Nonnull public static java.util.List<java.lang.String> splitArguments(java.lang.String commandArgs)
Example:
"/bin/bash -xc 'echo "hello" world!'"
results in ["/bin/bash", "-xc", "echo "hello" world!"]
commandArgs
- The original string representation of the command arguments@Nullable public static java.lang.String joinArguments(java.util.List<java.lang.String> commandArgs)
commandArgs
- The command arguments to join back together