Package com.jcabi.http.response
Class JacksonResponse
java.lang.Object
com.jcabi.http.response.JacksonResponse
- All Implemented Interfaces:
Response
A JSON response provided by the Jackson Project.
- Since:
- 1.17
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA tree representation views of JSON documents. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <T extends Response>
TConvert it to another type, by encapsulation.final Requestback()Get back to the request it's related to.final byte[]binary()Raw body as an array of bytes.body()Get body as a string, assuming it'sUTF-8(if there is something else that can't be translated into a UTF-8 string a runtime exception will be thrown).headers()Get a collection of all headers.json()Read the body as JSON.final Stringreason()Get status line reason phrase.final intstatus()Get status of the response as a positive integer number.final StringtoString()
-
Constructor Details
-
JacksonResponse
Ctor.- Parameters:
resp- Response
-
-
Method Details
-
json
Read the body as JSON.- Returns:
- JSON reader.
-
toString
-
back
Description copied from interface:ResponseGet back to the request it's related to. -
status
public final int status()Description copied from interface:ResponseGet status of the response as a positive integer number. -
reason
Description copied from interface:ResponseGet status line reason phrase. -
headers
Description copied from interface:ResponseGet a collection of all headers. -
body
Description copied from interface:ResponseGet body as a string, assuming it'sUTF-8(if there is something else that can't be translated into a UTF-8 string a runtime exception will be thrown).DISCLAIMER: The only encoding supported here is UTF-8. If the body of response contains any chars that can't be used and should be replaced with a "replacement character", a
RuntimeExceptionwill be thrown. If you need to use some other encodings, useResponse.binary()instead. -
binary
public final byte[] binary()Description copied from interface:ResponseRaw body as an array of bytes. -
as
Description copied from interface:ResponseConvert it to another type, by encapsulation.
-