Class JsonBody

  • All Implemented Interfaces:

    
    public final class JsonBody
    extends RequestBody
                        

    Represents the body of a network request containing JSON data.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final JSONObject getJsonObject() The JSON object to send in the request body.
      Unit writeToStream(BufferedSink bufferedSink) Writes the JSON object as a UTF-8 string to the provided BufferedSink.
      String getContentType() Gets the content type for JSON data.
      BufferedSource getSource() Gets a BufferedSource for reading the JSON data.
      • Methods inherited from class com.inmobi.media.network.okhttp.entity.body.RequestBody

        getEncoding
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JsonBody

        JsonBody(JSONObject jsonObject, Integer encoding)
        Parameters:
        encoding - The encoding of the JSON data.
    • Method Detail

      • writeToStream

         Unit writeToStream(BufferedSink bufferedSink)

        Writes the JSON object as a UTF-8 string to the provided BufferedSink.

        Parameters:
        bufferedSink - The sink to write the JSON data to.
      • getContentType

         String getContentType()

        Gets the content type for JSON data.

        Returns:

        The content type string, typically "application/json".

      • getSource

         BufferedSource getSource()

        Gets a BufferedSource for reading the JSON data.

        Returns:

        A BufferedSource containing the JSON data as a UTF-8 string.