java.lang.Object
com.google.gson.JsonParser
A parser to parse JSON into a parse tree of
JsonElements.- Since:
- 1.3
- Author:
- Inderjeet Singh, Joel Leitch
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.No need to instantiate this class, use the static methods instead. -
Method Summary
Modifier and TypeMethodDescriptionparse(JsonReader json) Deprecated.Deprecated.Deprecated.static JsonElementparseReader(JsonReader reader) Returns the next value from the JSON stream as a parse tree.static JsonElementparseReader(Reader reader) Parses the complete JSON string provided by the reader into a parse tree.static JsonElementparseString(String json) Parses the specified JSON string into a parse tree.
-
Constructor Details
-
JsonParser
Deprecated.No need to instantiate this class, use the static methods instead.
-
-
Method Details
-
parseString
Parses the specified JSON string into a parse tree. An exception is thrown if the JSON string has multiple top-level JSON elements, or if there is trailing data.The JSON string is parsed in lenient mode.
- Parameters:
json- JSON text- Returns:
- a parse tree of
JsonElements corresponding to the specified JSON - Throws:
JsonParseException- if the specified text is not valid JSONJsonSyntaxException- Since:
- 2.8.6
-
parseReader
Parses the complete JSON string provided by the reader into a parse tree. An exception is thrown if the JSON string has multiple top-level JSON elements, or if there is trailing data.The JSON data is parsed in lenient mode.
- Parameters:
reader- JSON text- Returns:
- a parse tree of
JsonElements corresponding to the specified JSON - Throws:
JsonParseException- if there is an IOException or if the specified text is not valid JSONJsonIOExceptionJsonSyntaxException- Since:
- 2.8.6
-
parseReader
public static JsonElement parseReader(JsonReader reader) throws JsonIOException, JsonSyntaxException Returns the next value from the JSON stream as a parse tree. Unlike the otherparsemethods, no exception is thrown if the JSON data has multiple top-level JSON elements, or if there is trailing data.The JSON data is parsed in lenient mode, regardless of the lenient mode setting of the provided reader. The lenient mode setting of the reader is restored once this method returns.
- Throws:
JsonParseException- if there is an IOException or if the specified text is not valid JSONJsonIOExceptionJsonSyntaxException- Since:
- 2.8.6
-
parse
Deprecated.- Throws:
JsonSyntaxException
-
parse
Deprecated.- Throws:
JsonIOExceptionJsonSyntaxException
-
parse
Deprecated.- Throws:
JsonIOExceptionJsonSyntaxException
-