jsonArrLen method

Future<int> jsonArrLen(
  1. String key, {
  2. String path = '\$',
})

jsonArrLen

Implementation

Future<int> jsonArrLen(String key, {String path = '\$'}) async {
  Object result = await _runWithRetryNew(() async {
    return (await RespCommandsTier1(_client!)
        .jsonArrLen(key: key, path: path));
  });

  if (result is RespType2<dynamic>) {
    final result1 = result.toArray().payload;
    if (result1 != null && result1.isNotEmpty) {
      return result1[0].payload as int;
    } else {
      throw Exception('jsonArrLen: No elements in the result list');
    }
  }

  final result1 = (result as RespType3<dynamic>).toArray().payload;
  if (result1 != null && result1.isNotEmpty) {
    return result1[0].payload as int;
  } else {
    throw Exception('jsonArrLen: No elements in the result list');
  }
}