Package com.eatthepath.json
Class JsonParser
java.lang.Object
com.eatthepath.json.JsonParser
An extremely simple JSON parser that interprets JSON objects as Java primitives. JSON types are mapped to Java types as follows:
| JSON type | Java type |
|---|---|
| string | String |
| number | Number (Long or Double) |
| object | Map<String, Object> |
| array | List<Object> |
| boolean | boolean |
| null | null |
JsonParser instances are not thread-safe; only one thread may safely use a single parser at a
time, but parsers can be reused (i.e. callers do not need to construct a new parser for each parsing operation).
- Since:
- 0.14.1
- Author:
- Jon Chambers
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionparseJsonObject(String jsonString) Parses the given JSON string as a JSON object.
-
Constructor Details
-
JsonParser
public JsonParser()Constructs a new JSON parser. Parsers are not thread-safe, but may be reused.
-
-
Method Details
-
parseJsonObject
Parses the given JSON string as a JSON object.- Parameters:
jsonString- the JSON string to parse- Returns:
- a Map representing the JSON object
- Throws:
ParseException- if the given JSON string could not be parsed as a JSON object for any reason
-