Skip to content

Commit

Permalink
feat: add convenience method: HttpTextResponse.bodyToJson
Browse files Browse the repository at this point in the history
  • Loading branch information
Tienisto committed Aug 16, 2024
1 parent 82f6b5a commit 9fa0d57
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.1

- feat: add convenience method: `HttpTextResponse.bodyToJson`

## 0.5.0

- feat: interceptors (e.g. `RetryInterceptor`)
Expand Down
4 changes: 4 additions & 0 deletions lib/src/model/response.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:convert';
import 'dart:typed_data';

import 'package:meta/meta.dart';
Expand Down Expand Up @@ -33,6 +34,9 @@ class HttpTextResponse extends HttpResponse {
required this.body,
});

/// Convenience method to parse the body as JSON.
dynamic get bodyToJson => jsonDecode(body);

@override
String toString() {
return 'HttpTextResponse(${version.name}, status: $statusCode)';
Expand Down

0 comments on commit 9fa0d57

Please sign in to comment.