Class JsonParser<T>

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

    public class JsonParser<T>
    extends Object
    Parser for Salt API responses.
    • 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​(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​(String jsonString)
        Parse JSON given as string.
        Parameters:
        jsonString - JSON input given as string
        Returns:
        The parsed object