jsonStrLenEnhanced method
JSON.STRLEN (Enhanced)
Returns lengths of string values at the specified paths.
Returns a list of lengths, or null if the key does not exist.
The list contains null for paths that are not strings.
Implementation
Future<List<int?>?> jsonStrLenEnhanced({
required String key,
required List<String> paths,
}) async {
if (paths.isEmpty) return [];
final futures = <Future<dynamic>>[];
for (final path in paths) {
futures.add(execute(<String>['JSON.STRLEN', key, path]));
}
try {
final results = await Future.wait(futures);
return results.map<int?>((result) {
final unwrapped = _unwrapOne(result);
if (unwrapped is int) return unwrapped;
return null;
}).toList();
} catch (e) {
if (e.toString().contains('NONEXISTENT')) return null;
rethrow;
}
}