parse static method

JSONTransformer? parse(
  1. String? transformers
)

Parses transformers to a JSONTransformer chain.

Implementation

static JSONTransformer? parse(String? transformers) {
  _registerTransformers();

  if (transformers == null) return null;

  transformers = _trimTransformers(transformers);

  JSONTransformer? root;

  JSONTransformer? t;

  LOOP:
  while (transformers!.isNotEmpty) {
    for (var tRegistered in _registeredTransformers.values) {
      var match = tRegistered.matches(transformers!);

      if (match != null) {
        var t2 = tRegistered.fromMatch(match);
        if (t != null) {
          t.then(t2);
        } else {
          root = t2;
        }

        t = t2;

        transformers = transformers.substring(match.end);
        transformers = _trimTransformers(transformers);

        continue LOOP;
      }
    }

    break;
  }

  return root;
}