from static method
Returns a JSONTransformer from transformers
. Parses if needed.
Implementation
static JSONTransformer? from(Object? transformers) {
if (transformers == null) return null;
if (transformers is JSONTransformer) return transformers;
if (transformers is String) {
return JSONTransformer.parse(transformers);
}
if (transformers is List) {
var list = transformers
.map((e) => JSONTransformer.from(e))
.whereType<JSONTransformer>()
.toList();
if (list.isEmpty) {
return null;
}
var root = list.removeAt(0);
root.thenChain(list);
return root;
}
return null;
}