getJsonPropertyAsString method

Future<String?> getJsonPropertyAsString(
  1. String property,
  2. Object body
)

Utility function to extract properties from JSON objects in language where this is cumbersome.

Parameters:

  • String property (required): JSON property name or dot separated path selector such as a.b.c

  • Object body (required):

Implementation

Future<String?> getJsonPropertyAsString(String property, Object body,) async {
  final response = await getJsonPropertyAsStringWithHttpInfo(property, body,);
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'String',) as String;

  }
  return null;
}