Class JsonParser<T>

  • Type Parameters:
    T - The result type this parser produces.

    public class JsonParser<T>
    extends java.lang.Object
    Parser for Salt API responses.
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonParser​(com.google.gson.reflect.TypeToken<T> type)
      Created a new JsonParser for the given type.
      JsonParser​(com.google.gson.reflect.TypeToken<T> type, com.google.gson.Gson gson)
      Created a new JsonParser for the given type.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T parse​(java.io.InputStream inputStream)
      Parses a Json response that has a direct representation as a Java class.
      T parse​(java.lang.String jsonString)
      Parse JSON given as string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • GSON

        public static final com.google.gson.Gson GSON
      • RUN_RESULTS

        public static final JsonParser<Return<java.util.List<java.util.Map<java.lang.String,​java.lang.Object>>>> RUN_RESULTS
      • MAP

        public static final JsonParser<java.util.Map<java.lang.String,​java.lang.Object>> MAP
      • type

        private final com.google.gson.reflect.TypeToken<T> type
      • gson

        private final com.google.gson.Gson gson
    • Constructor Detail

      • JsonParser

        public JsonParser​(com.google.gson.reflect.TypeToken<T> type)
        Created a new JsonParser for the given type.
        Parameters:
        type - A TypeToken describing the type this parser produces.
      • JsonParser

        public JsonParser​(com.google.gson.reflect.TypeToken<T> type,
                          com.google.gson.Gson gson)
        Created a new JsonParser for the given type.
        Parameters:
        type - A TypeToken describing the type this parser produces.
        gson - Gson instance to use for parsing.
    • Method Detail

      • parse

        public T parse​(java.io.InputStream inputStream)
        Parses a Json response that has a direct representation as a Java class.
        Parameters:
        inputStream - result stream to parse.
        Returns:
        The parsed value.
      • parse

        public T parse​(java.lang.String jsonString)
        Parse JSON given as string.
        Parameters:
        jsonString - JSON input given as string
        Returns:
        The parsed object