Package com.suse.salt.netapi.parser
Class JsonParser<T>
- java.lang.Object
-
- com.suse.salt.netapi.parser.JsonParser<T>
-
- Type Parameters:
T
- The result type this parser produces.
public class JsonParser<T> extends java.lang.Object
Parser for Salt API responses.
-
-
Field Summary
Fields Modifier and Type Field Description static JsonParser<Event>
EVENTS
private com.google.gson.Gson
gson
static com.google.gson.Gson
GSON
static JsonParser<java.util.Map<java.lang.String,java.lang.Object>>
MAP
static JsonParser<Return<java.util.List<java.util.Map<java.lang.String,java.lang.Object>>>>
RUN_RESULTS
static JsonParser<Return<java.util.List<java.util.Map<java.lang.String,Result<SSHRawResult>>>>>
RUNSSHRAW_RESULTS
static JsonParser<Stats>
STATS
static JsonParser<Return<java.lang.String>>
STRING
static JsonParser<Return<java.util.List<Token>>>
TOKEN
private com.google.gson.reflect.TypeToken<T>
type
-
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.
-
-
-
Field Detail
-
GSON
public static final com.google.gson.Gson GSON
-
STRING
public static final JsonParser<Return<java.lang.String>> STRING
-
TOKEN
public static final JsonParser<Return<java.util.List<Token>>> TOKEN
-
RUN_RESULTS
public static final JsonParser<Return<java.util.List<java.util.Map<java.lang.String,java.lang.Object>>>> RUN_RESULTS
-
RUNSSHRAW_RESULTS
public static final JsonParser<Return<java.util.List<java.util.Map<java.lang.String,Result<SSHRawResult>>>>> RUNSSHRAW_RESULTS
-
STATS
public static final JsonParser<Stats> STATS
-
MAP
public static final JsonParser<java.util.Map<java.lang.String,java.lang.Object>> MAP
-
EVENTS
public static final JsonParser<Event> EVENTS
-
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
-
-