asJson method
dynamic
asJson()
Returns this request/response body as a JSON object - either a Map
or a
List
.
This attempts to read this request/response body as a String and decode it to a JSON object. If no encoding is specified, it will use UTF-8, rather than the generic fallback from the response. Throws a FormatException if this request/response body cannot be decoded to text or if the text is not valid JSON.
Implementation
dynamic asJson() => json.decode(_asString(_encoding ?? utf8));