Class GPath<O>

  • Type Parameters:
    O - the selection result

    public class GPath<O>
    extends Object
    Allows to select values from GSON documents The eval method returns the selection result given a root JsonElement. GPath instances can be built either
    1. by starting from the last select step and adding the preceding selection steps in a fluent interface like manner (e.g. the GPath string().field("name") accesses the "name" field of a GSON document) or
    2. by using nested methods calls (e.g. the nested method calls field("name", string()) construct the same GSON path).
    • Constructor Detail

      • GPath

        public GPath​(java.util.function.Function<com.google.gson.JsonElement,​O> eval)
    • Method Detail

      • any

        public static GPath<com.google.gson.JsonElement> any()
      • object

        public static GPath<com.google.gson.JsonObject> object()
      • array

        public static GPath<com.google.gson.JsonArray> array()
      • map

        public <X> GPath<X> map​(java.util.function.Function<O,​X> f)
      • eval

        public O eval​(com.google.gson.JsonElement in)
        Returns the selection result given the root JsonElement.
        Parameters:
        in - the root element the evaluation is base on.
        Returns:
        in case that the GPath selects non-existing fields null is returned.