public class JsonFunctions
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static com.google.common.base.Function<java.lang.String,com.google.gson.JsonElement> |
asJson() |
static <T> com.google.common.base.Function<com.google.gson.JsonElement,T> |
cast(java.lang.Class<T> expected) |
static <T> com.google.common.base.Function<Maybe<com.google.gson.JsonElement>,T> |
castM(java.lang.Class<T> expected) |
static <T> com.google.common.base.Function<Maybe<com.google.gson.JsonElement>,T> |
castM(java.lang.Class<T> expected,
T defaultValue) |
static <T> com.google.common.base.Function<com.google.gson.JsonElement,java.util.List<T>> |
forEach(com.google.common.base.Function<com.google.gson.JsonElement,T> func) |
static <T> com.google.common.base.Function<com.google.gson.JsonElement,T> |
getPath(java.lang.String path)
returns an element from a single json primitive value given a full path
JsonPath |
static com.google.common.base.Function<com.google.gson.JsonElement,com.google.gson.JsonElement> |
walk(java.lang.Iterable<java.lang.String> elements)
returns a function which traverses the supplied path of entries in a json object (maps of maps of maps...),
|
static com.google.common.base.Function<com.google.gson.JsonElement,com.google.gson.JsonElement> |
walk(java.lang.String... elements)
as
walkM(Iterable) taking a series of strings (dot separators not respected here) |
static com.google.common.base.Function<com.google.gson.JsonElement,com.google.gson.JsonElement> |
walk(java.lang.String elementOrDotSeparatedElements)
as
walkM(Iterable) taking a single string consisting of a dot separated path |
static com.google.common.base.Function<Maybe<com.google.gson.JsonElement>,Maybe<com.google.gson.JsonElement>> |
walkM(java.lang.Iterable<java.lang.String> elements)
as
#walk(Iterable)) but working with objects which Maybe contain JsonElement ,
simply preserving a Maybe.absent() object if additional walks are requested upon it
(cf jquery) |
static com.google.common.base.Function<Maybe<com.google.gson.JsonElement>,Maybe<com.google.gson.JsonElement>> |
walkM(java.lang.String... elements)
as
#walk(String...)) and walk(Iterable) |
static com.google.common.base.Function<Maybe<com.google.gson.JsonElement>,Maybe<com.google.gson.JsonElement>> |
walkM(java.lang.String elements)
as
#walk(String)) and walk(Iterable) |
static com.google.common.base.Function<com.google.gson.JsonElement,com.google.gson.JsonElement> |
walkN(java.lang.Iterable<java.lang.String> elements)
as
#walk(Iterable)) but if any element is not found it simply returns null |
static com.google.common.base.Function<com.google.gson.JsonElement,com.google.gson.JsonElement> |
walkN(java.lang.String... elements)
as
#walk(String...)) but if any element is not found it simply returns null |
static com.google.common.base.Function<com.google.gson.JsonElement,com.google.gson.JsonElement> |
walkN(java.lang.String elements)
as
walk(String) but if any element is not found it simply returns null |
public static com.google.common.base.Function<java.lang.String,com.google.gson.JsonElement> asJson()
public static <T> com.google.common.base.Function<com.google.gson.JsonElement,java.util.List<T>> forEach(com.google.common.base.Function<com.google.gson.JsonElement,T> func)
public static com.google.common.base.Function<com.google.gson.JsonElement,com.google.gson.JsonElement> walk(java.lang.String elementOrDotSeparatedElements)
walkM(Iterable)
taking a single string consisting of a dot separated pathpublic static com.google.common.base.Function<com.google.gson.JsonElement,com.google.gson.JsonElement> walk(java.lang.String... elements)
walkM(Iterable)
taking a series of strings (dot separators not respected here)public static com.google.common.base.Function<com.google.gson.JsonElement,com.google.gson.JsonElement> walk(java.lang.Iterable<java.lang.String> elements)
java.util.NoSuchElementException
- if any path is not present as a key in that mappublic static com.google.common.base.Function<com.google.gson.JsonElement,com.google.gson.JsonElement> walkN(@Nullable java.lang.String elements)
walk(String)
but if any element is not found it simply returns nullpublic static com.google.common.base.Function<com.google.gson.JsonElement,com.google.gson.JsonElement> walkN(java.lang.String... elements)
#walk(String...))
but if any element is not found it simply returns nullpublic static com.google.common.base.Function<com.google.gson.JsonElement,com.google.gson.JsonElement> walkN(java.lang.Iterable<java.lang.String> elements)
#walk(Iterable))
but if any element is not found it simply returns nullpublic static com.google.common.base.Function<Maybe<com.google.gson.JsonElement>,Maybe<com.google.gson.JsonElement>> walkM(@Nullable java.lang.String elements)
#walk(String))
and walk(Iterable)
public static com.google.common.base.Function<Maybe<com.google.gson.JsonElement>,Maybe<com.google.gson.JsonElement>> walkM(java.lang.String... elements)
#walk(String...))
and walk(Iterable)
public static com.google.common.base.Function<Maybe<com.google.gson.JsonElement>,Maybe<com.google.gson.JsonElement>> walkM(java.lang.Iterable<java.lang.String> elements)
#walk(Iterable))
but working with objects which Maybe
contain JsonElement
,
simply preserving a Maybe.absent()
object if additional walks are requested upon it
(cf jquery)public static <T> com.google.common.base.Function<com.google.gson.JsonElement,T> getPath(java.lang.String path)
JsonPath
public static <T> com.google.common.base.Function<com.google.gson.JsonElement,T> cast(java.lang.Class<T> expected)
public static <T> com.google.common.base.Function<Maybe<com.google.gson.JsonElement>,T> castM(java.lang.Class<T> expected)
public static <T> com.google.common.base.Function<Maybe<com.google.gson.JsonElement>,T> castM(java.lang.Class<T> expected, T defaultValue)