Class JsonParser

java.lang.Object
com.eatthepath.json.JsonParser

public class JsonParser
extends Object

An extremely simple JSON parser that interprets JSON objects as Java primitives. JSON types are mapped to Java types as follows:

Mapping of JSON types to Java types
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 Details

    • JsonParser

      public JsonParser()
      Constructs a new JSON parser. Parsers are not thread-safe, but may be reused.
  • Method Details

    • parseJsonObject

      public Map<String,​Object> parseJsonObject​(String jsonString) throws ParseException
      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