Class JSONElement

java.lang.Object
kong.unirest.core.json.JSONElement
Direct Known Subclasses:
JSONArray, JSONObject

public abstract class JSONElement extends Object
  • Field Details

    • MAPPER

      protected static final transient kong.unirest.core.json.ToObjectMapper MAPPER
  • Constructor Details

  • Method Details

    • write

      public Writer write(Writer sw) throws JSONException
      Write the JSON to a Writer
      Parameters:
      sw - the writer
      Returns:
      the same Writer
      Throws:
      JSONException - for IO problems
    • write

      public Writer write(Writer sw, int indentFactor, int indent) throws JSONException
      Write the JSON to a Writer with a pretty format due to limitations in GSON the index and indent are currently ignored
      Parameters:
      sw - the writer
      indentFactor - currently ignored
      indent - currently ignored
      Returns:
      the same Writer
      Throws:
      JSONException - for IO problems
    • query

      public Object query(String query)
      query the object graph using JSONPointer https://tools.ietf.org/html/rfc6901
      Parameters:
      query - the pointer to get
      Returns:
      the thing you asked for
    • query

      public Object query(JSONPointer query)
      query the object graph using JSONPointer https://tools.ietf.org/html/rfc6901
      Parameters:
      query - the pointer to get
      Returns:
      the thing you asked for
    • optQuery

      public Object optQuery(String query)
    • optQuery

      public Object optQuery(JSONPointer query)
    • getElement

      public JsonEngine.Element getElement()
    • toPrettyJson

      protected static String toPrettyJson(JsonEngine.Element obj)
    • toMap

      protected static Map<String,Object> toMap(JsonEngine.Element obj)