jsonArrIndex method

Future<int> jsonArrIndex(
  1. String key,
  2. Object value, {
  3. String path = '\$',
  4. int? start,
  5. int? end,
})

jsonArrIndex

Implementation

Future<int> jsonArrIndex(
  String key,
  Object value, {
  String path = '\$',
  int? start,
  int? end,
}) async {
  List<RespType<dynamic>>? result = await _runWithRetryNew(() async {
    return (await RespCommandsTier1(_client!).jsonArrIndex(
      key: key,
      path: path,
      value: value,
      start: start,
      end: end,
    ))
        .toArray()
        .payload;
  });
  if (result != null && result.isNotEmpty) {
    return result[0].payload as int; // 确保 payload 是 int 类型
  } else {
    throw Exception('jsonArrAppend: No elements in the result list');
  }
}